Coder Social home page Coder Social logo

osamaqarem / react-native-freeotp Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 2.0 465 KB

Generate the same TOTP tokens as FreeOTP from your React Native app.

License: MIT License

Kotlin 3.34% Java 33.78% JavaScript 2.79% TypeScript 0.73% Swift 42.98% Objective-C 7.00% Ruby 8.52% Starlark 0.87%

react-native-freeotp's Introduction

react-native-freeotp

Native module for generating the same TOTP tokens as FreeOTP from your React Native app.

Installation

npm install react-native-freeotp

Android

Rebuild the app.

iOS

Install the pod, then rebuild the app.

npx pod-install

Usage

import FreeOtp from 'react-native-freeotp';

const tokenPair = await FreeOtp.getTokenPair(totpUrl);

Types

Result:

type TokenPair = {
  /**
   * Current token.
   */
  tokenOne: string;
  /**
   * Next period step token.
   */
  tokenTwo: string;
  /**
   * Seconds until expiry of the current token.
   */
  tokenOneExpires: string;
  /**
   * Seconds until expiry of the next token.
   */
  tokenTwoExpires: string;
};

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

react-native-freeotp's People

Contributors

dependabot[bot] avatar har0ld-scl avatar osamaqarem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

react-native-freeotp's Issues

iOS - UnsafePointer fatal crash on Xcode 14 simulator

After upgrading to Xcode 14 me and my team have experience issues developing with the iOS Simulator due to a fatal crash.

The crash occurs when generating the code in the following lines:

// ios/Core/OTP.swift ~ func code ~ line 121
let msk = UnsafePointer<UInt8>(buf).advanced(by: off).withMemoryRebound(to: UInt32.self, capacity: size/4) {
     $0[0].bigEndian & 0x7fffffff
}

Additionally in Xcode that line shows the following compilation warning: "Initialization of 'UnsafePointer' results in a dangling pointer".

Based on this commit replacing that lines with the ones of the commit solves the problem.

// Fix
let bin_code = Array(buf[off...off + 3])
var msk = bin_code.withUnsafeBytes {
     $0.load(as: UInt32.self).bigEndian
}
msk &= 0x7fffffff

I've already tested the fix and I'll submit a pull request with the changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.