Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

@instantdb/core

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@instantdb/core - npm Package Compare versions

Comparing version 0.5.17 to 0.6.0

@@ -12,2 +12,7 @@ export function sendMagicCode({ apiURI, appId, email, }: {

}): Promise<any>;
export function verifyRefreshToken({ apiURI, appId, refreshToken, }: {
apiURI: any;
appId: any;
refreshToken: any;
}): Promise<any>;
//# sourceMappingURL=authAPI.d.ts.map

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.verifyMagicCode = exports.sendMagicCode = void 0;
exports.verifyRefreshToken = exports.verifyMagicCode = exports.sendMagicCode = void 0;
const fetch_1 = require("./utils/fetch");

@@ -34,2 +34,16 @@ function sendMagicCode({ apiURI, appId, email, }) {

exports.verifyMagicCode = verifyMagicCode;
function verifyRefreshToken({ apiURI, appId, refreshToken, }) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield (0, fetch_1.jsonFetch)(`${apiURI}/runtime/auth/verify_refresh_token`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
'app-id': appId,
'refresh-token': refreshToken
}),
});
return res;
});
}
exports.verifyRefreshToken = verifyRefreshToken;
//# sourceMappingURL=authAPI.js.map

@@ -9,3 +9,3 @@ import { assert } from "./utils/error";

import { Query, QueryResponse, InstantObject, Exactly } from "./queryTypes";
declare function getDB(): any;
declare function getDB(): ReactiveDB;
export type Config = {

@@ -16,3 +16,4 @@ appId: string;

};
declare function init(config: Config, Storage?: any, NetworkListener?: any): any;
type AuthToken = string;
declare function init(config: Config, Storage?: any, NetworkListener?: any): ReactiveDB;
/**

@@ -41,3 +42,3 @@ * Use this to write data! You can create, update, delete, and link objects

*/
declare function transact(chunks: TransactionChunk | TransactionChunk[]): any;
declare function transact(chunks: TransactionChunk | TransactionChunk[]): void;
declare function getLocalId(name: string): Promise<string>;

@@ -54,3 +55,3 @@ declare function coerceQuery(o: any): any;

*
* Once you send the magic code, see {@link auth.verifyMagicCode} to let the
* Once you send the magic code, see {@link auth.signInWithMagicCode} to let the
* user verify.

@@ -65,3 +66,3 @@ *

email: string;
}): any;
}): Promise<any>;
/**

@@ -73,13 +74,24 @@ * Verify a magic code that was sent to the user's email address.

* @example
* auth.verifyMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
* auth.signInWithMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
*/
verifyMagicCode(params: {
signInWithMagicCode(params: {
email: string;
code: string;
}): any;
}): Promise<any>;
/**
* TODO
*/
signInWithToken(token: AuthToken): Promise<void>;
/**
* Sign out the current user
*/
signOut(): void;
/**
* @deprecated since version 0.5.17. Use {@link auth.signInWithMagicCode} instead.
*/
verifyMagicCode(params: {
email: string;
code: string;
}): Promise<any>;
};

@@ -119,19 +131,8 @@ type SubscriptionState<Q> = {

*/
declare function subscribeQuery<Q extends Query>(query: Exactly<Query, Q>, cb: (resp: SubscriptionState<Q>) => void): any;
declare function subscribeQuery<Q extends Query>(query: Exactly<Query, Q>, cb: (resp: SubscriptionState<Q>) => void): () => void;
type User = {
id: string;
email: string;
refresh_token: string;
};
/**
* React-related types
*
* (XXX): Right now there is some copy-pasta
* in `@instantdb/react` and `@instantdb/react-native`
*
* To reduce as much as we can, I went ahead and moved
* some of the shared types here.
*
* Eventually we may want a `react-shared` package, but
* this does enough for now.
*/
type AuthState = {

@@ -167,3 +168,3 @@ isLoading: true;

};
export { init, getDB, getLocalId, transact, assert, ReactiveDB, weakHash, tx, id, IndexedDBStorage, WindowNetworkListener, coerceQuery, auth, Query, QueryResponse, InstantObject, Exactly, subscribeQuery, TransactionChunk, getOps, QueryState, AuthState, User, };
export { init, getDB, getLocalId, transact, assert, ReactiveDB, weakHash, tx, id, IndexedDBStorage, WindowNetworkListener, coerceQuery, auth, Query, QueryResponse, InstantObject, Exactly, subscribeQuery, TransactionChunk, getOps, QueryState, AuthState, User, AuthToken, };
//# sourceMappingURL=index.d.ts.map

@@ -91,3 +91,3 @@ "use strict";

*
* Once you send the magic code, see {@link auth.verifyMagicCode} to let the
* Once you send the magic code, see {@link auth.signInWithMagicCode} to let the
* user verify.

@@ -110,10 +110,17 @@ *

* @example
* auth.verifyMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
* auth.signInWithMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
*/
verifyMagicCode(params) {
signInWithMagicCode(params) {
const db = getDB();
return db.verifyMagicCode(params);
return db.signInWithMagicCode(params);
},
/**
* TODO
*/
signInWithToken(token) {
const db = getDB();
return db.signInWithCustomToken(token);
},
/**
* Sign out the current user

@@ -125,2 +132,8 @@ */

},
/**
* @deprecated since version 0.5.17. Use {@link auth.signInWithMagicCode} instead.
*/
verifyMagicCode(params) {
return auth.signInWithMagicCode(params);
},
};

@@ -127,0 +140,0 @@ exports.auth = auth;

@@ -12,2 +12,7 @@ export function sendMagicCode({ apiURI, appId, email, }: {

}): Promise<any>;
export function verifyRefreshToken({ apiURI, appId, refreshToken, }: {
apiURI: any;
appId: any;
refreshToken: any;
}): Promise<any>;
//# sourceMappingURL=authAPI.d.ts.map

@@ -28,2 +28,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
export function verifyRefreshToken({ apiURI, appId, refreshToken, }) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield jsonFetch(`${apiURI}/runtime/auth/verify_refresh_token`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
'app-id': appId,
'refresh-token': refreshToken
}),
});
return res;
});
}
//# sourceMappingURL=authAPI.js.map

@@ -9,3 +9,3 @@ import { assert } from "./utils/error";

import { Query, QueryResponse, InstantObject, Exactly } from "./queryTypes";
declare function getDB(): any;
declare function getDB(): ReactiveDB;
export type Config = {

@@ -16,3 +16,4 @@ appId: string;

};
declare function init(config: Config, Storage?: any, NetworkListener?: any): any;
type AuthToken = string;
declare function init(config: Config, Storage?: any, NetworkListener?: any): ReactiveDB;
/**

@@ -41,3 +42,3 @@ * Use this to write data! You can create, update, delete, and link objects

*/
declare function transact(chunks: TransactionChunk | TransactionChunk[]): any;
declare function transact(chunks: TransactionChunk | TransactionChunk[]): void;
declare function getLocalId(name: string): Promise<string>;

@@ -54,3 +55,3 @@ declare function coerceQuery(o: any): any;

*
* Once you send the magic code, see {@link auth.verifyMagicCode} to let the
* Once you send the magic code, see {@link auth.signInWithMagicCode} to let the
* user verify.

@@ -65,3 +66,3 @@ *

email: string;
}): any;
}): Promise<any>;
/**

@@ -73,13 +74,24 @@ * Verify a magic code that was sent to the user's email address.

* @example
* auth.verifyMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
* auth.signInWithMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
*/
verifyMagicCode(params: {
signInWithMagicCode(params: {
email: string;
code: string;
}): any;
}): Promise<any>;
/**
* TODO
*/
signInWithToken(token: AuthToken): Promise<void>;
/**
* Sign out the current user
*/
signOut(): void;
/**
* @deprecated since version 0.5.17. Use {@link auth.signInWithMagicCode} instead.
*/
verifyMagicCode(params: {
email: string;
code: string;
}): Promise<any>;
};

@@ -119,19 +131,8 @@ type SubscriptionState<Q> = {

*/
declare function subscribeQuery<Q extends Query>(query: Exactly<Query, Q>, cb: (resp: SubscriptionState<Q>) => void): any;
declare function subscribeQuery<Q extends Query>(query: Exactly<Query, Q>, cb: (resp: SubscriptionState<Q>) => void): () => void;
type User = {
id: string;
email: string;
refresh_token: string;
};
/**
* React-related types
*
* (XXX): Right now there is some copy-pasta
* in `@instantdb/react` and `@instantdb/react-native`
*
* To reduce as much as we can, I went ahead and moved
* some of the shared types here.
*
* Eventually we may want a `react-shared` package, but
* this does enough for now.
*/
type AuthState = {

@@ -167,3 +168,3 @@ isLoading: true;

};
export { init, getDB, getLocalId, transact, assert, ReactiveDB, weakHash, tx, id, IndexedDBStorage, WindowNetworkListener, coerceQuery, auth, Query, QueryResponse, InstantObject, Exactly, subscribeQuery, TransactionChunk, getOps, QueryState, AuthState, User, };
export { init, getDB, getLocalId, transact, assert, ReactiveDB, weakHash, tx, id, IndexedDBStorage, WindowNetworkListener, coerceQuery, auth, Query, QueryResponse, InstantObject, Exactly, subscribeQuery, TransactionChunk, getOps, QueryState, AuthState, User, AuthToken, };
//# sourceMappingURL=index.d.ts.map

@@ -72,3 +72,3 @@ import { assert } from "./utils/error";

*
* Once you send the magic code, see {@link auth.verifyMagicCode} to let the
* Once you send the magic code, see {@link auth.signInWithMagicCode} to let the
* user verify.

@@ -91,10 +91,17 @@ *

* @example
* auth.verifyMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
* auth.signInWithMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
*/
verifyMagicCode(params) {
signInWithMagicCode(params) {
const db = getDB();
return db.verifyMagicCode(params);
return db.signInWithMagicCode(params);
},
/**
* TODO
*/
signInWithToken(token) {
const db = getDB();
return db.signInWithCustomToken(token);
},
/**
* Sign out the current user

@@ -106,2 +113,8 @@ */

},
/**
* @deprecated since version 0.5.17. Use {@link auth.signInWithMagicCode} instead.
*/
verifyMagicCode(params) {
return auth.signInWithMagicCode(params);
},
};

@@ -108,0 +121,0 @@ /**

@@ -97,6 +97,7 @@ export default class ReactiveDB {

}): Promise<any>;
verifyMagicCode({ email, code }: {
signInWithMagicCode({ email, code }: {
email: any;
code: any;
}): Promise<any>;
signInWithCustomToken(authToken: any): Promise<void>;
signOut(): void;

@@ -103,0 +104,0 @@ }

@@ -650,3 +650,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
verifyMagicCode({ email, code }) {
signInWithMagicCode({ email, code }) {
return __awaiter(this, void 0, void 0, function* () {

@@ -663,2 +663,12 @@ const res = yield authAPI.verifyMagicCode({

}
signInWithCustomToken(authToken) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield authAPI.verifyRefreshToken({
apiURI: this.config.apiURI,
appId: this.config.appId,
refreshToken: authToken,
});
this.changeCurrentUser(res.user);
});
}
signOut() {

@@ -665,0 +675,0 @@ this.changeCurrentUser(null);

@@ -97,6 +97,7 @@ export default class ReactiveDB {

}): Promise<any>;
verifyMagicCode({ email, code }: {
signInWithMagicCode({ email, code }: {
email: any;
code: any;
}): Promise<any>;
signInWithCustomToken(authToken: any): Promise<void>;
signOut(): void;

@@ -103,0 +104,0 @@ }

@@ -678,3 +678,3 @@ "use strict";

}
verifyMagicCode({ email, code }) {
signInWithMagicCode({ email, code }) {
return __awaiter(this, void 0, void 0, function* () {

@@ -691,2 +691,12 @@ const res = yield authAPI.verifyMagicCode({

}
signInWithCustomToken(authToken) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield authAPI.verifyRefreshToken({
apiURI: this.config.apiURI,
appId: this.config.appId,
refreshToken: authToken,
});
this.changeCurrentUser(res.user);
});
}
signOut() {

@@ -693,0 +703,0 @@ this.changeCurrentUser(null);

{
"name": "@instantdb/core",
"version": "0.5.17",
"version": "0.6.0",
"description": "Instant's core local abstraction",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -32,1 +32,20 @@ import { jsonFetch } from "./utils/fetch";

export async function verifyRefreshToken({
apiURI,
appId,
refreshToken,
}) {
const res = await jsonFetch(
`${apiURI}/runtime/auth/verify_refresh_token`,
{
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
'app-id': appId,
'refresh-token': refreshToken
}),
}
);
return res;
}

@@ -10,3 +10,3 @@ import { assert } from "./utils/error";

let _GLOBAL_DB: any;
let _GLOBAL_DB: ReactiveDB;

@@ -28,2 +28,4 @@ function getDB() {

type AuthToken = string;
function init(config: Config, Storage?: any, NetworkListener?: any) {

@@ -93,3 +95,3 @@ // (XXX): This is some hackery, to make

*
* Once you send the magic code, see {@link auth.verifyMagicCode} to let the
* Once you send the magic code, see {@link auth.signInWithMagicCode} to let the
* user verify.

@@ -112,10 +114,19 @@ *

* @example
* auth.verifyMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
* auth.signInWithMagicCode({email: "example@gmail.com", code: "123456"})
* .catch((err) => console.error(err.body?.message))
*/
verifyMagicCode(params: { email: string; code: string }) {
signInWithMagicCode(params: { email: string; code: string }) {
const db = getDB();
return db.verifyMagicCode(params);
return db.signInWithMagicCode(params);
},
/**
* TODO
*/
signInWithToken(token: AuthToken) {
const db = getDB();
return db.signInWithCustomToken(token);
},
/**
* Sign out the current user

@@ -127,2 +138,10 @@ */

},
/**
* @deprecated since version 0.5.17. Use {@link auth.signInWithMagicCode} instead.
*/
verifyMagicCode(params: { email: string; code: string }) {
return auth.signInWithMagicCode(params);
},
};

@@ -165,16 +184,15 @@

type User = { id: string; email: string };
type User = { id: string; email: string; refresh_token: string };
/**
* React-related types
*
* (XXX): Right now there is some copy-pasta
* in `@instantdb/react` and `@instantdb/react-native`
*
* To reduce as much as we can, I went ahead and moved
* some of the shared types here.
*
* Eventually we may want a `react-shared` package, but
* this does enough for now.
*/
// ----
// React-related types
//
// (XXX): Right now there is some copy-pasta
// in `@instantdb/react` and `@instantdb/react-native`
//
// To reduce as much as we can, I went ahead and moved
// some of the shared types here.
//
// Eventually we may want a `react-shared` package, but
// this does enough for now.

@@ -215,2 +233,3 @@ type AuthState =

User,
AuthToken,
};

@@ -735,3 +735,3 @@ import log from "./utils/log";

async verifyMagicCode({ email, code }) {
async signInWithMagicCode({ email, code }) {
const res = await authAPI.verifyMagicCode({

@@ -747,2 +747,11 @@ apiURI: this.config.apiURI,

async signInWithCustomToken(authToken) {
const res = await authAPI.verifyRefreshToken({
apiURI: this.config.apiURI,
appId: this.config.appId,
refreshToken: authToken,
})
this.changeCurrentUser(res.user);
}
signOut() {

@@ -749,0 +758,0 @@ this.changeCurrentUser(null);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet