🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@instantdb/react

Package Overview
Dependencies
Maintainers
2
Versions
317
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@instantdb/react - npm Package Compare versions

Comparing version

to
0.5.0

26

dist/index.d.ts

@@ -19,2 +19,28 @@ import { instatx, getLocalId as getLocalIdCore, Config, transact as transactCore } from "@instantdb/core";

export declare function useQuery<T = any>(_query: any): QueryState<T>;
type AuthState = {
isLoading: true;
error: undefined;
user: undefined;
} | {
isLoading: false;
error: {
message: string;
};
user: undefined;
} | {
isLoading: false;
error: undefined;
user: string;
};
export declare function useAuth(): AuthState;
export declare const auth: {
sendMagicCode(params: {
email: string;
}): any;
verifyMagicCode(params: {
email: string;
code: string;
}): any;
signOut(): void;
};
export declare const id: (<T extends ArrayLike<number>>(options: import("uuid").V4Options, buffer: T, offset?: number) => T) & ((options?: import("uuid").V4Options) => string);

@@ -21,0 +47,0 @@ export declare const tx: instatx.EmptyChunk;

32

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLocalId = exports.transact = exports.tx = exports.id = exports.useQuery = exports.init = void 0;
exports.getLocalId = exports.transact = exports.tx = exports.id = exports.auth = exports.useAuth = exports.useQuery = exports.init = void 0;
const core_1 = require("@instantdb/core");

@@ -30,2 +30,32 @@ const react_1 = require("react");

exports.useQuery = useQuery;
function useAuth() {
const db = (0, core_1.getDB)();
const [state, setState] = (0, react_1.useState)({
isLoading: true,
user: undefined,
error: undefined,
});
(0, react_1.useEffect)(() => {
const unsub = db.subscribeAuth((resp) => {
setState(Object.assign({ isLoading: false }, resp));
});
return unsub;
}, []);
return state;
}
exports.useAuth = useAuth;
exports.auth = {
sendMagicCode(params) {
const db = (0, core_1.getDB)();
return db.sendMagicCode(params);
},
verifyMagicCode(params) {
const db = (0, core_1.getDB)();
return db.verifyMagicCode(params);
},
signOut() {
const db = (0, core_1.getDB)();
db.signOut();
},
};
exports.id = core_1.uuid;

@@ -32,0 +62,0 @@ exports.tx = core_1.instatx.tx;

@@ -19,2 +19,28 @@ import { instatx, getLocalId as getLocalIdCore, Config, transact as transactCore } from "@instantdb/core";

export declare function useQuery<T = any>(_query: any): QueryState<T>;
type AuthState = {
isLoading: true;
error: undefined;
user: undefined;
} | {
isLoading: false;
error: {
message: string;
};
user: undefined;
} | {
isLoading: false;
error: undefined;
user: string;
};
export declare function useAuth(): AuthState;
export declare const auth: {
sendMagicCode(params: {
email: string;
}): any;
verifyMagicCode(params: {
email: string;
code: string;
}): any;
signOut(): void;
};
export declare const id: (<T extends ArrayLike<number>>(options: import("uuid").V4Options, buffer: T, offset?: number) => T) & ((options?: import("uuid").V4Options) => string);

@@ -21,0 +47,0 @@ export declare const tx: instatx.EmptyChunk;

@@ -25,2 +25,31 @@ import { getDB, weakHash, instatx, uuid, init as initCore, getLocalId as getLocalIdCore, transact as transactCore, coerceQuery, } from "@instantdb/core";

}
export function useAuth() {
const db = getDB();
const [state, setState] = useState({
isLoading: true,
user: undefined,
error: undefined,
});
useEffect(() => {
const unsub = db.subscribeAuth((resp) => {
setState(Object.assign({ isLoading: false }, resp));
});
return unsub;
}, []);
return state;
}
export const auth = {
sendMagicCode(params) {
const db = getDB();
return db.sendMagicCode(params);
},
verifyMagicCode(params) {
const db = getDB();
return db.verifyMagicCode(params);
},
signOut() {
const db = getDB();
db.signOut();
},
};
export const id = uuid;

@@ -27,0 +56,0 @@ export const tx = instatx.tx;

4

package.json
{
"name": "@instantdb/react",
"version": "0.4.3",
"version": "0.5.0",
"description": "Instant DB for React",

@@ -31,4 +31,4 @@ "main": "dist/index.js",

"dependencies": {
"@instantdb/core": "0.4.3"
"@instantdb/core": "0.5.0"
}
}

@@ -45,2 +45,39 @@ import {

type AuthState =
| { isLoading: true; error: undefined; user: undefined }
| { isLoading: false; error: { message: string }; user: undefined }
| { isLoading: false; error: undefined; user: string };
export function useAuth(): AuthState {
const db = getDB();
const [state, setState] = useState({
isLoading: true,
user: undefined,
error: undefined,
});
useEffect(() => {
const unsub = db.subscribeAuth((resp: any) => {
setState({ isLoading: false, ...resp });
});
return unsub;
}, []);
return state;
}
export const auth = {
sendMagicCode(params: { email: string }) {
const db = getDB();
return db.sendMagicCode(params);
},
verifyMagicCode(params: { email: string; code: string }) {
const db = getDB();
return db.verifyMagicCode(params);
},
signOut() {
const db = getDB();
db.signOut();
},
};
export const id = uuid;

@@ -47,0 +84,0 @@ export const tx = instatx.tx;

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