
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@luneo7/react-native-ntp-sync
Advanced tools
React Native compatible implementation of the NTP Client Protocol.
Used to ensure the time used is in sync across distributed systems. The sync is achieved by the following process:
npm i @luneo7/react-native-ntp-sync
React Native Version >=0.60.0 - react-native-udp for more information.
yarn add @luneo7/react-native-ntp-sync or npm install @luneo7/react-native-ntp-sync.yarn add react-native-udp or npm install react-native-udp.pod install in ios directory.Import the module into your codebase
import ntpClient from '@luneo7/react-native-ntp-sync';
Create an instance of the clock object passing in the required params. See the options section below for options that can be used.
var options = {};
// create a new instance
var clock = ntp = new ntpSync(options);
// get the current unix timestamp
var currentTime = clock.getTime();
console.log(currentTime);
// manually sync the time
var result = await clock.syncTime();
The client constructor can accept the following options. all options are optional
autoSync (boolean) : A flag to control if the client will do automatic synchronizatin. Defaults to truehistory (+int) : The number of delta values that should be maintained and used for calculating your local time drift. Defaults to 10 if not present, zero, or supplied value is not a number. Supplied value must be > 0servers (array of NtpServer) { server: string; port: number; } : The server used to do the NTP synchronization. Defaults to[
{ server: "time.google.com", port: 123 },
{ server: "time.cloudflare.com", port: 123 },
{ server: "0.pool.ntp.org", port: 123 },
{ server: "1.pool.ntp.org", port: 123 },
]
syncInterval (+number) : The time (in milliseconds) between each call to an NTP server to get the latest UTC timestamp. Defaults to 5 minutessyncOnCreation (boolean) : A flag to control the NTP sync upon instantiation. Defaults to true. (immediate NTP server fetch attempt)syncTimeout (+number) : The timeout (in milliseconds) that will be used in every NTP syncronization . Defaults to 10 seconds{
"history": 10,
"syncOnCreation": false,
...
}
Returns an Object of historical details generated as clockSync runs. It includes several fields that can be used to determine the behavior of a running clockSync instance. Each call represents an individual 'snapshot' of the current clockSync instance. History is not updated when instance is offline.
currentConsecutiveErrorCount (int) : Count of current string of errors since entering an error state (isInErrorState === true). Resets to 0 upon successful sync.currentServer (object) : Object containing server info of the server that will be used for the next sync. Props are:
server (string) : the NTP server nameport (int) : the NTP portdeltas (array<object>) : This array will contain a 'rolling' list of raw time values returned from each successful NTP server sync wrapped in a simple object with the following keys: (note: array length is limited to config.history; oldest at index 0)
dt (+/- int) : The calculated delta (in ms) between local time and the value returned from NTP.ntp (int) : The unix epoch-relative time (in ms) returned from the NTP server. (raw value returned from server) note: ntp + -1(dt) = local time of syncerrors (array<object>) : This array will contain a 'rolling' list of any errors that have occurred during sync attempts. (note: array length is limited to config.history; oldest at index 0). The object contains typical fields found in JS Errors as well as additional information.
name (string) : JavaScript Error namemessage (string) : JavaScript Error messageserver (object) : The server that encountered the sync error. Same keys as currentServer object. (possibly different values)stack (string) : JavaScript Error stack trace (if available)time (int) : The local unix epoch-relative timestamp when error was encountered (in ms)isInErrorState (boolean) : Flag indicating if the last attempted sync was an error (true) Resets to false upon successful sync.lastSyncTime (int) : The local unix epoch-relative timestamp of last successful sync (in ms)lastNtpTime (int) : The NTP unix epoch-relative timestamp of the last successful sync (raw value returned from server)lastError (object) : The error info of the last sync error that was encountered. Object keys are same as objects in the errors array.lifetimeErrorCount (int) : A running total of all errors encountered since clockSync instance was created.maxConsecutiveErrorCount (int) : Greatest number of errors in a single error state (before a successful sync).Returns unix timestamp based on delta values between server and your local time. This is the time that can be used instead of new Date().getTime()
An on-demand method that will force a sync with an NTP server.
NOTE: You generally do not need to invoke a manual sync since ntpClient automatically runs sync according to the specified syncInterval interval (or its default).
An on-demand method that will start auto sync according to the specified syncInterval interval (or its default).
An on-demand method that will stop auto sync according.
@jet/react0native-ntp-client is based on react-native-clock-sync and react-native-ntp-client by Artem Russkikh
FAQs
Sync time using NTP servers
We found that @luneo7/react-native-ntp-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.