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

gapi-oauth-react-hooks

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gapi-oauth-react-hooks - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

7

hooks/use.gapi.loading.hook.d.ts
/// <reference types="gapi.auth2" />
/// <reference types="react" />
export declare enum GapiState {
Loading = 0,
SignedIn = 1,
NotSignedIn = 2,
Errored = 3
}
export declare type GapiState = "Loading" | "SignedIn" | "NotSignedIn" | "Errored";
export declare const useGapiLoading: () => readonly [GapiState, gapi.auth2.BasicProfile | undefined, import("react").Dispatch<import("react").SetStateAction<gapi.auth2.BasicProfile | undefined>>, import("react").Dispatch<import("react").SetStateAction<GapiState>>];

15

hooks/use.gapi.loading.hook.js
import { useEffect, useState } from "react";
import { loadScript, removeScript } from "../logic/resource.loading.logic";
import { useGapiConfig } from "./use.gapi.config.hook";
export var GapiState;
(function (GapiState) {
GapiState[GapiState["Loading"] = 0] = "Loading";
GapiState[GapiState["SignedIn"] = 1] = "SignedIn";
GapiState[GapiState["NotSignedIn"] = 2] = "NotSignedIn";
GapiState[GapiState["Errored"] = 3] = "Errored";
})(GapiState || (GapiState = {}));
export var useGapiLoading = function () {
var config = useGapiConfig();
var _a = useState(GapiState.Loading), state = _a[0], setState = _a[1];
var _a = useState("Loading"), state = _a[0], setState = _a[1];
var _b = useState(), user = _b[0], setUser = _b[1];

@@ -20,6 +13,6 @@ var setSignedInUser = function (gapi, isMounted) {

setUser(gapi.currentUser.get().getBasicProfile());
setState(GapiState.SignedIn);
setState("SignedIn");
}
else {
setState(GapiState.NotSignedIn);
setState("NotSignedIn");
}

@@ -34,3 +27,3 @@ };

if (!GoogleAuth) {
window.gapi.auth2.init(config).then(function (res) { return setSignedInUser(res, isMounted); }, function (err) { return setState(GapiState.Errored); });
window.gapi.auth2.init(config).then(function (res) { return setSignedInUser(res, isMounted); }, function (err) { return setState("Errored"); });
}

@@ -37,0 +30,0 @@ else {

/// <reference types="gapi.auth2" />
import { GapiState } from "./use.gapi.loading.hook";
export declare const useGapiLogin: () => readonly [GapiState, gapi.auth2.BasicProfile | undefined, () => Promise<void>, () => Promise<void>];
export declare const useGapiLogin: () => readonly [import("./use.gapi.loading.hook").GapiState, gapi.auth2.BasicProfile | undefined, () => Promise<void>, () => Promise<void>];

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

};
import { GapiState, useGapiLoading } from "./use.gapi.loading.hook";
import { useGapiLoading } from "./use.gapi.loading.hook";
export var useGapiLogin = function () {

@@ -46,3 +46,3 @@ var _a = useGapiLoading(), gapiState = _a[0], signedUser = _a[1], setSignedUser = _a[2], setGapiState = _a[3];

case 0:
if (gapiState !== GapiState.NotSignedIn)
if (gapiState !== "NotSignedIn")
throw new Error("gapi is not ready for sign in");

@@ -57,3 +57,3 @@ _a.label = 1;

setSignedUser(user.getBasicProfile());
setGapiState(GapiState.SignedIn);
setGapiState("SignedIn");
return [3 /*break*/, 4];

@@ -63,3 +63,3 @@ case 3:

console.log("gapi login error:", err_1);
setGapiState(GapiState.Errored);
setGapiState("Errored");
return [3 /*break*/, 4];

@@ -75,3 +75,3 @@ case 4: return [2 /*return*/];

case 0:
if (gapiState !== GapiState.SignedIn)
if (gapiState !== "SignedIn")
return [2 /*return*/];

@@ -78,0 +78,0 @@ authInstance = window.gapi.auth2.getAuthInstance();

@@ -1,4 +0,3 @@

import { GapiState } from "./hooks/use.gapi.loading.hook";
import { useGapiLogin } from "./hooks/use.gapi.login.hook";
import { GapiConfig } from "./logic/gapi.config.logic";
export { useGapiLogin, GapiConfig, GapiState };
export { useGapiLogin, GapiConfig };

@@ -1,4 +0,3 @@

import { GapiState } from "./hooks/use.gapi.loading.hook";
import { useGapiLogin } from "./hooks/use.gapi.login.hook";
import { GapiConfig } from "./logic/gapi.config.logic";
export { useGapiLogin, GapiConfig, GapiState };
export { useGapiLogin, GapiConfig };
{
"name": "gapi-oauth-react-hooks",
"version": "1.0.3",
"version": "1.0.4",
"repository": "https://github.com/jpb06/gapi-oauth-react-hooks.git",

@@ -5,0 +5,0 @@ "author": "jpb06 <jpb.06@outlook.com>",

@@ -94,2 +94,3 @@ # gapi-oauth-react-hooks

- 1.0.4 : Removing the GapiState enum; replacing it with a type to simplify rendering in react components.
- 1.0.3 : Misc: readme alterations.

@@ -96,0 +97,0 @@ - 1.0.2 : It's es5 we want to publish... Yes.

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