Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

laudep/surge-auth-generator

Open more actions menu

Repository files navigation

surge-auth-generator

Generate AUTH files for basic authentication in surge.sh projects

NPM Version Github Actions Dependency Status Codecov

Description

surge-auth-generator helps generate AUTH files for setting up basic authentication on surge.sh projects.
It makes supporting case insensitive users a breeze.
See surge help for more info on authentication using AUTH files.

Installation

$ npm install --save-dev surge-auth-generator

Usage

Import

const authGenerator = require('surge-auth-generator');
authGenerator.generate(credentials, directory);

or

const { generate } = require('surge-auth-generator');
generate(credentials, directory);

Examples

Create AUTH file in project root for john:doe.

authGenerator.generate({
    username: 'john',
    password: 'doe'
});

Create AUTH file with case insensitive username in project root
(so authentication will work for 'John', 'john', 'JOHN', ...).

authGenerator.generate({
    username: 'john',
    password: 'doe',
    caseInsensitive: 'true'
});

Create AUTH file in dist folder for multiple users.

authGenerator.generate(
    [{
        username: 'john',
        password: 'doe'
    }, {
        username: 'jane',
        password: 'doe'
    }, {
        username: 'foo',
        password: 'bar'
    }], "dist");

Documentation

Credentials

The package works with a custom object type for authentication credentials.
Each property is optional and can be left out.
The special property caseInsensitive can be used to indicate that a username is not case sensitive.

/**
 * @interface Credential
 */
interface Credential {
    /** authentication username */
    username?: string;
    /** authentication password */



    password?: string;
    /** whether the username should be case insensitive */
    caseInsensitive?: boolean;
}

Generate function

AUTH files can be created using the generate function.
The method takes in a credential object or an array of credentials and an optional output path.
All parameters are optional.
The output path defaults to the current project's root directory.

const generate: (credentials?: Credential | Credential[], directory?: string | undefined) => Promise<string>

License

MIT

About

AUTH file generator for basic authentication on surge.sh

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.