1.0.7 • Published 4 years ago

surge-auth-generator v1.0.7

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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.

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

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago