3.2.18 • Published 4 months ago

@liveart/auth v3.2.18

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
4 months ago

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),
});
3.2.18

4 months ago

3.2.17

4 months ago

3.2.16

5 months ago

3.2.15

5 months ago

3.2.13

5 months ago

3.2.12

5 months ago

3.2.14

5 months ago

3.2.11

5 months ago

3.2.10

5 months ago

3.2.9

5 months ago

3.2.8

5 months ago

3.2.7

5 months ago

3.2.6

5 months ago

2.2.3

8 months ago

2.2.2

8 months ago

2.2.5

7 months ago

2.2.4

7 months ago

3.2.2

5 months ago

3.2.1

5 months ago

3.2.0

6 months ago

3.2.5

5 months ago

3.2.4

5 months ago

3.2.3

5 months ago

3.0.0

6 months ago

3.1.0

6 months ago

2.2.1

11 months ago

2.2.0

11 months ago

2.0.11

1 year ago

2.0.12

1 year ago

2.0.9

1 year ago

2.0.10

1 year ago

2.0.8

1 year ago

2.1.0

1 year ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago