npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@os-team/auth-mobile

v1.2.3

Published

The authentication module for os-team's mobile apps.

Downloads

118

Readme

@os-team/auth-mobile NPM version BundlePhobia

The authentication module for os-team's mobile apps.

Installation

Install the package using the following command:

yarn add @os-team/auth-mobile

Install peer dependencies:

npx install-peerdeps @os-team/auth-mobile

Install pods:

npx pod-install

Add to the ios/MyProject/Info.plist file the following key:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>message</string>
    <string>readdle-spark</string>
    <string>airmail</string>
    <string>ms-outlook</string>
    <string>googlegmail</string>
    <string>inbox-gmail</string>
    <string>ymail</string>
    <string>superhuman</string>
    <string>yandexmail</string>
</array>

Add to the android/app/src/main/AndroidManifest.xml file inside the manifest tag the following content:

<queries>
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="mailto"/>
  </intent>
</queries>

Replace the NavigationContainer from the @react-navigation/native package with the AuthNavigationContainer from the @os-team/auth-mobile package as follows:

import 'react-native-gesture-handler';
import React from 'react';
import { useColorScheme } from 'react-native';
import { RelayEnvironmentProvider } from 'react-relay/hooks';
import { ThemeProvider } from '@os-design-mobile/theming';
import createRelayEnvironment from './utils/createRelayEnvironment';
import AuthenticatedNavigator, {
  authenticatedInitialRouteName,
  authenticatedScreens,
} from './screens/AuthenticatedNavigator';
import { AuthNavigationContainer } from '@os-team/auth-mobile';

require('./i18next');

const PREFIXES = ['englika://', 'https://englika.com', 'https://englika.ru'];

const relayEnvironment = createRelayEnvironment();

const App: React.FC = () => {
  const colorScheme = useColorScheme();

  return (
    <RelayEnvironmentProvider environment={relayEnvironment}>
      <ThemeProvider initialTheme={colorScheme || undefined}>
        <AuthNavigationContainer
          secondLevelDomain='englika'
          linking={{
            prefixes: PREFIXES,
            config: {
              initialRouteName: authenticatedInitialRouteName,
              screens: authenticatedScreens,
            },
          }}
        >
          <AuthenticatedNavigator />
        </AuthNavigationContainer>
      </ThemeProvider>
    </RelayEnvironmentProvider>
  );
};

export default App;

Add locales in the i18next options:

import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import RNLanguageDetector from '@os-team/i18next-react-native-language-detector';
import { locales } from '@os-team/auth-mobile';

i18next
  .use(RNLanguageDetector)
  .use(initReactI18next)
  .init({
    fallbackLng: 'en',
    supportedLngs: ['en', 'ru'],
    ns: [],
    defaultNS: undefined,

    resources: {
      en: {
        auth: locales.en, // Add this line
      },
      ru: {
        auth: locales.ru, // Add this line
      },
    },

    interpolation: {
      escapeValue: false,
    },
  });

export default i18next;

Add the token middleware:

import { Environment, RecordSource, Store } from 'relay-runtime';
import createRelayNetwork from '@os-team/relay-network-creator';
import { token } from '@os-team/auth-mobile';

let environment: Environment;

const createRelayEnvironment = (): Environment => {
  if (!environment) {
    environment = new Environment({
      network: createRelayNetwork({
        url: 'http://192.168.0.103:4000/graphql',
        middlewares: [token],
      }),
      store: new Store(new RecordSource()),
    });
  }

  return environment;
};

export default createRelayEnvironment;

Sign out

To sign out, call the asynchronous signOut method from the useAuth hook.

Example of usage:

import React from 'react';
import { View } from 'react-native';
import { StackNavigationProp } from '@react-navigation/stack';
import Button from '@os-design-mobile/button';
import Paragraph from '@os-design-mobile/paragraph';
import { RouteProp } from '@react-navigation/native';
import { AuthenticatedStackParams } from './AuthenticatedStack';
import { useAuth } from '../../lib';

interface HomeScreenProps {
  route: RouteProp<AuthenticatedStackParams, 'Home'>;
  navigation: StackNavigationProp<AuthenticatedStackParams, 'Home'>;
}

const HomeScreen: React.FC<HomeScreenProps> = () => {
  const { signOut } = useAuth();

  return (
    <View>
      <Paragraph>Congratulations! You are signed in.</Paragraph>
      <Button
        onPress={async () => {
          await signOut();
        }}
      >
        Sign out
      </Button>
    </View>
  );
};

export default HomeScreen;