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

@descope/react-sdk

Package Overview
Dependencies
Maintainers
4
Versions
619
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@descope/react-sdk - npm Package Compare versions

Comparing version 0.0.52-alpha.4 to 0.0.52-alpha.5

38

dist/index.d.ts

@@ -1,4 +0,12 @@

import React, { DOMAttributes, FC } from 'react';
/// <reference types="react" />
import React, { FC, DOMAttributes } from 'react';
import DescopeWc from '@descope/web-component';
interface IAuthProviderProps {
projectId: string;
baseUrl?: string;
children?: JSX.Element;
}
declare const AuthProvider: FC<IAuthProviderProps>;
declare global {

@@ -42,3 +50,15 @@ namespace JSX {

}
interface DescopeProps {
flowId: string;
onSuccess?: DescopeCustomElement['onsuccess'];
onError?: DescopeCustomElement['onerror'];
}
declare type DefaultFlowProps = Omit<DescopeProps, 'flowId'>;
declare const SignInFlow: (props: DefaultFlowProps) => JSX.Element;
declare const SignUpFlow: (props: DefaultFlowProps) => JSX.Element;
declare const SignUpOrInFlow: (props: DefaultFlowProps) => JSX.Element;
declare const Descope: React.ForwardRefExoticComponent<DescopeProps & React.RefAttributes<HTMLElement>>;
declare const useAuth: () => {

@@ -52,16 +72,2 @@ projectId: string;

interface PropsType {
flowId: string;
onSuccess?: DescopeCustomElement['onsuccess'];
onError?: DescopeCustomElement['onerror'];
}
declare const Descope: React.ForwardRefExoticComponent<PropsType & React.RefAttributes<HTMLElement>>;
interface IAuthProviderProps {
projectId: string;
baseUrl?: string;
children?: JSX.Element;
}
declare const AuthProvider: FC<IAuthProviderProps>;
export { AuthProvider, Descope, useAuth };
export { AuthProvider, Descope, SignInFlow, SignUpFlow, SignUpOrInFlow, useAuth };

@@ -1,1 +0,1 @@

import e,{useMemo as t,useRef as r,useImperativeHandle as s,useCallback as o,useEffect as n,useState as c}from"react";import"@descope/web-component";const d=e.createContext(void 0),i=()=>{const r=e.useContext(d);if(!r)throw Error("You can only use useAuth in the context of <AuthProvider />");const{projectId:s,baseUrl:o,authenticated:n,user:c,sessionToken:i}=r;return t((()=>({projectId:s,baseUrl:o,authenticated:n,user:c,sessionToken:i})),[s,o,n,c,i])},u=e.forwardRef((({flowId:t,onSuccess:c,onError:i},u)=>{const a=r();s(u,(()=>a.current));const{projectId:l,baseUrl:p,setAuthenticated:v,setUser:h,setSessionToken:f}=e.useContext(d),E=o((e=>{h(e.detail?.user),v(!0),f(e.detail?.sessionJwt),c&&c(e)}),[h,v,c]);return n((()=>{const e=a.current;return e?.addEventListener("success",E),i&&e?.addEventListener("error",i),()=>{i&&e?.removeEventListener("error",i),e?.removeEventListener("success",E)}}),[a,i,E]),e.createElement("descope-wc",{"project-id":l,"flow-id":t,"base-url":p,ref:a})}));u.defaultProps={onError:void 0,onSuccess:void 0};const a=({projectId:r,baseUrl:s,children:o})=>{const[n,i]=c(!1),[u,a]=c({}),[l,p]=c(""),v=t((()=>({projectId:r,baseUrl:s,user:u,authenticated:n,sessionToken:l,setUser:a,setAuthenticated:i,setSessionToken:p})),[n,u,r,s]);return e.createElement(d.Provider,{value:v},o)};a.defaultProps={baseUrl:"",children:void 0};export{a as AuthProvider,u as Descope,i as useAuth};
import e,{useState as t,useMemo as r,useRef as s,useImperativeHandle as o,useCallback as n,useEffect as c}from"react";import"@descope/web-component";const i=e.createContext(void 0),d=({projectId:s,baseUrl:o,children:n})=>{const[c,d]=t(!1),[u,a]=t({}),[l,p]=t(""),f=r((()=>({projectId:s,baseUrl:o,user:u,authenticated:c,sessionToken:l,setUser:a,setAuthenticated:d,setSessionToken:p})),[c,u,s,o]);return e.createElement(i.Provider,{value:f},n)};d.defaultProps={baseUrl:"",children:void 0};const u=e.forwardRef((({flowId:t,onSuccess:r,onError:d},u)=>{const a=s();o(u,(()=>a.current));const{projectId:l,baseUrl:p,setAuthenticated:f,setUser:v,setSessionToken:E}=e.useContext(i),h=n((e=>{v(e.detail?.user),f(!0),E(e.detail?.sessionJwt),r&&r(e)}),[v,f,r]);return c((()=>{const e=a.current;return e?.addEventListener("success",h),d&&e?.addEventListener("error",d),()=>{d&&e?.removeEventListener("error",d),e?.removeEventListener("success",h)}}),[a,d,h]),e.createElement("descope-wc",{"project-id":l,"flow-id":t,"base-url":p,ref:a})}));u.defaultProps={onError:void 0,onSuccess:void 0};const a=t=>e.createElement(u,{...t,flowId:"sign-in"}),l=t=>e.createElement(u,{...t,flowId:"sign-up"}),p=t=>e.createElement(u,{...t,flowId:"sign-up-or-in"}),f=()=>{const t=e.useContext(i);if(!t)throw Error("You can only use useAuth in the context of <AuthProvider />");const{projectId:s,baseUrl:o,authenticated:n,user:c,sessionToken:d}=t;return r((()=>({projectId:s,baseUrl:o,authenticated:n,user:c,sessionToken:d})),[s,o,n,c,d])};export{d as AuthProvider,u as Descope,a as SignInFlow,l as SignUpFlow,p as SignUpOrInFlow,f as useAuth};
{
"name": "@descope/react-sdk",
"version": "0.0.52-alpha.4",
"version": "0.0.52-alpha.5",
"main": "dist/index.js",

@@ -16,3 +16,3 @@ "types": "dist/index.d.ts",

"dependencies": {
"@descope/web-component": "^0.0.26-alpha.5"
"@descope/web-component": "^0.0.26-alpha.7"
},

@@ -19,0 +19,0 @@ "devDependencies": {

@@ -27,4 +27,26 @@ # @descope/react-sdk

#### Use Descope to render specific flow
You can use default flows or provide flow id directly to the Descope component
##### Default flows
```js
// you can choose flow to run from the following
// import { SignIn } from '@descope/react-sdk'
// import { SignUp } from '@descope/react-sdk'
import { SignUpOrIn } from '@descope/react-sdk'
const App = () => {
return (
{...}
<SignUpOrIn
onSuccess={(e) => console.log('Logged in!')}
onError={(e) => console.log('Could not logged in!')}
/>
)
}
```
##### Provide flow id
```js
import { Descope } from '@descope/react-sdk'

@@ -39,3 +61,3 @@

onError={(e) => console.log('Could not logged in!')}
>
/>
)

@@ -45,3 +67,12 @@ }

TODO:
- decide about the callbacks event data & structure
## Contributing to this project
In order to use this repo locally
- Clone this repository
- Navigate to repository directory
- Run `npm i`
- Edit `src/app/index.tsx` in the following way
- Set `projectId` prop - replace `<project-id>` with your project id
- Set `flowId` prop - Replace `<flow-id>` (for example - `sign-up-or-in`)
- Optional - set a different `baseUrl` (for example - `http://localhost:8000`)
- Run `npm run start`
- Go to `http://localhost:3000/` and start flow
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