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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ping-identity/rn-protect

v1.1.0-beta.0

Published

Ping Identity Protect library for React Native, enabling Risk/Protect data collection in DaVinci flows.

Readme

Ping Identity

Ping Identity React Native Protect

The Ping Protect library integrates PingOne Protect behavioral data collection into your React Native application. Acting as a plugin for the davinci module, it runs silent background risk signals collection during a DaVinci flow so that your backend can make an informed authentication decision.

Table of contents

Overview

When a DaVinci flow includes a PROTECT collector, the native PingOne Protect SDK collects behavioral and device signals in the background. This library bridges that native collection to your React Native app — call collectProtect(daVinci) from @ping-identity/rn-protect before advancing the flow, and the collected payload is forwarded automatically on the next daVinci.next({}) call.

No foreground window, activity, or user interaction is required. Collection runs entirely in the background.

Installation

Note: This module requires that @ping-identity/rn-core and @ping-identity/rn-davinci are already installed.

yarn add @ping-identity/rn-protect
# iOS only
cd ios && pod install

Optional integration:

yarn add @ping-identity/rn-logger

Usage

DaVinci lifecycle integration

Initialize Protect before the first DaVinci operation. createDaVinciClient remains responsible only for DaVinci configuration; startProtect owns Protect initialization and lifecycle registration.

import { createDaVinciClient } from '@ping-identity/rn-davinci';
import { startProtect } from '@ping-identity/rn-protect';
import { logger } from '@ping-identity/rn-logger';

const protectLogger = logger({ level: 'debug' });

await startProtect({
  envId: 'your-pingone-environment-id',
  isBehavioralDataCollection: true,
  pauseBehavioralDataOnSuccess: true,
  resumeBehavioralDataOnStart: true,
  logger: protectLogger,
});

const client = createDaVinciClient({
  logger: protectLogger,
  modules: {
    oidc: {
      clientId: 'rn-client',
      discoveryEndpoint:
        'https://auth.pingone.com/<env-id>/as/.well-known/openid-configuration',
      redirectUri: 'com.example.app://callback',
      scopes: ['openid'],
    },
  },
});

await client.start();

The DaVinci client may be created before startProtect, because configuration is lazy, but startProtect must resolve before client.start() or any other DaVinci operation.

When the lifecycle integration is active, call collectProtect from @ping-identity/rn-protect before advancing the flow:

import { collectProtect } from '@ping-identity/rn-protect';

await collectProtect(daVinci);
await daVinci.next({});

Manual initialization

Use this path when you need direct control over initialization timing, or when using Protect outside a DaVinci flow.

1. Initialize the Protect SDK

import { startProtect } from '@ping-identity/rn-protect';

await startProtect({
  envId: 'your-pingone-environment-id',
  isBehavioralDataCollection: true,
  resumeBehavioralDataOnStart: true,
});

With optional logger:

import { startProtect } from '@ping-identity/rn-protect';
import { logger } from '@ping-identity/rn-logger';

const protectLogger = logger({ level: 'debug' });

await startProtect({
  envId: 'your-pingone-environment-id',
  logger: protectLogger,
});

2. Collect for a DaVinci flow

Import collectProtect from @ping-identity/rn-protect and pass the DaVinci client:

import { collectProtect } from '@ping-identity/rn-protect';

try {
  await collectProtect(daVinci);
  const node = await daVinci.next({});
} catch (error) {
  // See Errors section
}

3. Pause and resume behavioral data collection

Control behavioral data collection manually to mirror the ProtectLifecycleModule behavior from the native SDK. Call pauseBehavioralData() after a successful flow and resumeBehavioralData() when a new flow starts.

import {
  pauseBehavioralData,
  resumeBehavioralData,
} from '@ping-identity/rn-protect';

// After a successful authentication flow:
await pauseBehavioralData();

// At the start of a new authentication flow:
await resumeBehavioralData();

With an optional logger:

await pauseBehavioralData({ logger: protectLogger });
await resumeBehavioralData({ logger: protectLogger });

If you set resumeBehavioralDataOnStart: true in startProtect, it calls resumeBehavioralData() automatically after initialization.

4. Use with useDaVinciForm

Pass handledCollectorTypes so PROTECT collectors are excluded from blocking submit issues. Without this, buildNextInput returns canSubmit: false when a PROTECT collector is present.

import { useDaVinci, useDaVinciForm } from '@ping-identity/rn-davinci';
import {
  collectProtect,
  protectCollectorType,
} from '@ping-identity/rn-protect';

const { node, next } = useDaVinci(daVinciClient);
const form = useDaVinciForm(node, {
  handledCollectorTypes: new Set([protectCollectorType]),
});

// Before submitting the form, run collection:
await collectProtect(daVinciClient);

if (form.canSubmit) {
  await next(form.input);
}

5. Full example

import React, { useEffect } from 'react';
import {
  useDaVinci,
  useDaVinciForm,
  createDaVinciClient,
} from '@ping-identity/rn-davinci';
import {
  collectProtect,
  protectCollectorType,
} from '@ping-identity/rn-protect';

const daVinciClient = createDaVinciClient({
  modules: {
    oidc: {
      /* ... */
    },
  },
});

function LoginScreen() {
  const { node, next } = useDaVinci(daVinciClient);
  const form = useDaVinciForm(node, {
    handledCollectorTypes: new Set([protectCollectorType]),
  });

  useEffect(() => {
    if (node?.type !== 'ContinueNode') return;
    const hasProtect = node.collectors.some(
      (c) => c.type === protectCollectorType,
    );
    if (!hasProtect) return;

    collectProtect(daVinciClient).catch(console.error);
  }, [node]);

  async function handleSubmit() {
    if (!form.canSubmit) return;
    await next(form.input);
  }

  // ... render form fields
}

API reference

import {
  collectProtect,
  startProtect,
  pauseBehavioralData,
  resumeBehavioralData,
} from '@ping-identity/rn-protect';
import type {
  ProtectConfig,
  ProtectErrorCode,
} from '@ping-identity/rn-protect';

function collectProtect(daVinci: DaVinciInstance): Promise<void>;
function startProtect(config?: ProtectConfig): Promise<void>;
function pauseBehavioralData(options?: {
  logger?: LoggerInstance;
}): Promise<void>;
function resumeBehavioralData(options?: {
  logger?: LoggerInstance;
}): Promise<void>;

interface ProtectConfig {
  /** Optional logger instance from @ping-identity/rn-logger. */
  logger?: LoggerInstance;
  /** PingOne environment ID for the Protect SDK. */
  envId?: string;
  /** Whether to enable behavioral data collection. Default: true. */
  isBehavioralDataCollection?: boolean;
  /** Whether to use lazy metadata loading. Default: false. */
  isLazyMetadata?: boolean;
  /** Custom host URL for the Protect SDK. */
  customHost?: string;
  /** Whether to enable console logging inside the Protect SDK. Default: false. */
  isConsoleLogEnabled?: boolean;
  /** Device attributes to exclude from signal collection. */
  deviceAttributesToIgnore?: string[];
  /** When true, startProtect() resumes behavioral data collection automatically. Default: false. */
  resumeBehavioralDataOnStart?: boolean;
  /** Documents intent to pause after success — call pauseBehavioralData() manually. Default: false. */
  pauseBehavioralDataOnSuccess?: boolean;
}

Errors

All promise rejections throw a ProtectError instance, which extends PingError extends Error. Use instanceof to narrow the error type:

import { collectProtect, ProtectError } from '@ping-identity/rn-protect';

try {
  await collectProtect(daVinci);
} catch (err) {
  if (err instanceof ProtectError) {
    console.log(err.code, err.message);
  }
}

Stable error codes:

  • PROTECT_INITIALIZE_ERROR — the native Protect SDK failed to initialize, pause, or resume.
  • PROTECT_COLLECT_ERROR — the native Protect SDK failed to collect signals.
  • PROTECT_COLLECTOR_NOT_FOUND — no active PROTECT collector was found for the current DaVinci flow.

License

This project is licensed under the MIT License - see the LICENSE file for details.