Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@cognite/dune-fe-auth

Package Overview
Dependencies
Maintainers
261
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cognite/dune-fe-auth

Authentication utilities for Cognite Data Fusion React applications

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
261
Created
Source

@cognite/dune-fe-auth

Authentication utilities for Cognite Data Fusion React applications.

Installation

npm install @cognite/dune-fe-auth

Usage

CDFAuthenticationProvider

Wrap your application with the CDFAuthenticationProvider to provide CDF SDK context:

import { CDFAuthenticationProvider } from '@cognite/dune-fe-auth';

function App() {
  return (
    <CDFAuthenticationProvider>
      <YourAppComponents />
    </CDFAuthenticationProvider>
  );
}

useCDF Hook

Use the useCDF hook to access the Cognite SDK in your components:

import { useCDF } from '@cognite/dune-fe-auth';

function MyComponent() {
  const { sdk } = useCDF();
  
  // Use the SDK to interact with CDF
  const assets = await sdk.assets.list();
  
  return <div>...</div>;
}

Utilities

The package also exports utility functions for authentication:

import { getToken, getLocalHostSDK, EMPTY_SDK } from '@cognite/dune-fe-auth';

// Get an access token
const token = await getToken(clientId, clientSecret);

// Get a configured SDK for localhost development
const sdk = await getLocalHostSDK();

Environment Variables

For localhost development, ensure these environment variables are set:

  • PROJECT - Your CDF project name
  • BASE_URL - CDF base URL
  • CLIENT_ID - OAuth client ID
  • CLIENT_SECRET - OAuth client secret

Setup

  • Copy the provided template file:

    cp .env.template .env
    
  • Fill in your actual values in the .env file

Peer Dependencies

This package requires:

  • @cognite/sdk ^8.0.0
  • react ^18.0.0

Development

# Install dependencies
npm install

# Build the package
npm run build

# Watch for changes during development
npm run dev

# Preview the built package
npm run preview

# Type check
npm run type-check

Publishing

npm publish

License

MIT

Keywords

cognite

FAQs

Package last updated on 31 Aug 2025

Did you know?

Socket

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.

Install

Related posts