Skip to content

clavin/electron-native-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Electron Native Authentication

Integration of native OS authentication services for Electron apps.

API

Class: AuthRequest

A request to receive authentication from a resource. The request must specify what URL scheme it expects the authentication callback to come from.

Example:

import { AuthRequest } from "electron-native-auth";

if (AuthRequest.isAvailable()) {
  const req = new AuthRequest({
    url,
    callbackScheme,
    windowHandle: myBrowserWindow.getNativeWindowHandle(),
  });

  const result = await req.start();
} else {
  console.error("Native auth request unavailable :(");
}

Static Method: isAvailable()

Indicates if this API is available on the current platform. This method is always available, even if the current platform is not supported.

  • Parameters: None.
  • Returns: A boolean, true if the rest of this class' methods are supported on the current platform.

Constructor

Initializes, but does not start, an authentication request. A request can be started and later cancelled.

  • Parameters:
    • Options (object):
      • url (string): The URL to authenticate to.
      • callbackScheme (string): The URL scheme (the part before ://) that the callback is expected to have.
      • windowHandle (Buffer): The native OS window handle for the window requesting authentication. Used when the OS prompts the user for authentication.
      • headers ({ [header: string]: string }, optional, macOS 14.4+): Headers and their values to add to HTTP requests sent during the authentication session.

Method: start()

Begins the request to authenticate.

  • Parameters: None.
  • Returns: A Promise that resolves (with undefined) when the request has finished.

Method: cancel()

Cancels the authentication request.

  • Parameters: None.
  • Returns: Nothing.

Supported Platforms

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •