Socket
Book a DemoInstallSign in
Socket

@liveart/auth

Package Overview
Dependencies
Maintainers
5
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liveart/auth

LiveArt npm packages

3.2.18
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
5
Weekly downloads
 
Created
Source

Liveart Stytch authentication

Liveart authentication package for Stytch implementation.

Installation

Use the npm package manager to install the package into the project.

npm install @liveart/auth

Initialization

Mobile

Run init function to initialize the the workplace (reducer, token storage etc).

import { init } from '@liveart/auth';
import * as Keychain from 'react-native-keychain';
import { store } from './store';

...

init({
  dispatch: store.dispatch,
  storage: Keychain,
  userServiceAddress: 'https://user-dev.liveart.ai',
})

WEB

Run init function to initialize the the workplace (reducer, token storage etc).

import { init } from '@liveart/auth';
import { store } from './store';

...

init({
  dispatch: store.dispatch,
  storage: localStorage,
  userServiceAddress: 'https://user-dev.liveart.ai',
})

Attach reducer and configure saga middleware

Reducer

Attach reducer to your store

import { stytchReducer } from '@liveart/auth';
import { combineReducers } from '@reduxjs/toolkit';

...

const rootReducer = combineReducers({
  ...
  stytch: stytchReducer,
  ...
});

Saga middleware

Attach saga to the saga middleware

import { stytchSaga, stytchSignOut } from '@liveart/auth';
import createSagaMiddleware from 'redux-saga';

...

const sagaMiddleware = createSagaMiddleware()
sagaMiddleware.run(function* () {
  yield all([
    ...
    stytchSaga(),
    ...
  ]);
});

Configure Store

Configure Redux store

import { configureStore } from '@reduxjs/toolkit';

...

const store = configureStore({
  ...
  middleware: (getDefaultMiddleware) => {
    return getDefaultMiddleware({
      serializableCheck: {
        ignoredActions: [getSoldArtworksByArtistId.toString()],
      },
    }).concat(sagaMiddleware);
  },
  ...
});

Usage/Examples

Current step

import { StytchStep, stytchStepSelector } from '@liveart/auth';

const stytchStep = useSelector(stytchStepSelector);

Email sign Up

import {
  StytchStep,
  stytchStepSelector,
  stytchEmailSignUp,
} from '@liveart/auth';

dispatch(
  stytchEmailSignUp({
    email: '<EMAIL@TEST.COM>',
    name: {
      firstName: '<FIRST_NAME>',
      lastName: '<LAST_NAME>',
    },
    enableNewsletter: true,
    termsAccepted: true,
  }),
);

Email exchange code

Exchange the core (which is received via email) for the accessToken

import { stytchStepSelector } from '@liveart/auth';

dispatch(
  stytchEmailExchangeCode({
    code: '<CODE>',
    enableNewsletter: true,
    termsAccepted: true,
  }),
);

Apollo client

Create apollo client with the following configs

import { createApolloAuthenticationLink } from '@liveart/auth';

const client = new ApolloClient({
  uri: '<APOLLO URI>',
  link: createApolloAuthenticationLink(uri),
});

FAQs

Package last updated on 02 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.