# csc-server

> CSC Framework RSSP in Node.js

Latest version **1.0.6** (published 2020-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install csc-server
pnpm add csc-server
yarn add csc-server
bun add csc-server
```

Provides the command `csc-server`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2020-02-05 |
| First published | 2020-02-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 25 |
| Unpacked size | 111.3 KB |
| Known vulnerabilities | 0 (+8 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Simion Robert |
| Maintainers | simion.robert.george |
| Keywords | digital signature, cloud signature consortium, remote service signature provider, signature, csc |

## Links

- npm: https://www.npmjs.com/package/csc-server
- Repository: https://github.com/simionrobert/CSC-Framework
- Homepage: https://github.com/simionrobert/CSC-Framework#readme
- Issues: https://github.com/simionrobert/CSC-Framework/issues
- npm.io page: https://npm.io/package/csc-server

## Dependencies (25)

- [ejs](https://npm.io/package/ejs.md) ^3.0.1
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [helmet](https://npm.io/package/helmet.md) ^3.21.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [morgan](https://npm.io/package/morgan.md) ^1.9.1
- [express](https://npm.io/package/express.md) ^4.17.1
- [winston](https://npm.io/package/winston.md) ^3.2.1
- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [mongoose](https://npm.io/package/mongoose.md) ^5.8.11
- [passport](https://npm.io/package/passport.md) ^0.4.1
- [validator](https://npm.io/package/validator.md) ^12.2.0
- [@fidm/x509](https://npm.io/package/@fidm/x509.md) ^1.2.1
- [base64-url](https://npm.io/package/base64-url.md) ^2.3.3
- [portfinder](https://npm.io/package/portfinder.md) ^1.0.25
- [http-errors](https://npm.io/package/http-errors.md) ^1.7.3
- [oauth2orize](https://npm.io/package/oauth2orize.md) ^1.11.0
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.4.4
- [passport-http](https://npm.io/package/passport-http.md) ^0.3.0
- [passport-local](https://npm.io/package/passport-local.md) ^1.0.0
- [express-session](https://npm.io/package/express-session.md) ^1.17.0
- [passport-custom](https://npm.io/package/passport-custom.md) ^1.1.0
- [connect-ensure-login](https://npm.io/package/connect-ensure-login.md) ^0.1.1
- [passport-http-bearer](https://npm.io/package/passport-http-bearer.md) ^1.0.1
- [passport-oauth2-client-password](https://npm.io/package/passport-oauth2-client-password.md) ^0.1.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2020-02-05
- 1.0.5 — 2020-02-05
- 1.0.4 — 2020-02-04
- 1.0.1 — 2020-02-04
- 1.0.0 — 2020-02-04

## README

# CSC - Cloud Signature Consortium

![Build Status](https://github.com/simionrobert/cloud-signature-consortium/workflows/Node.js%20CI/badge.svg) [![Dependency Status](https://david-dm.org/simionrobert/CSC-Framework/status.svg)](https://david-dm.org/simionrobert/CSC-Framework)

A CSC RSSP -Cloud Signature Consortium Remote Signature Service Provider-, written in Node.js using SoftHSMv2 as HSM.
This application follows the [CSC API V1.0.4.0](https://cloudsignatureconsortium.org/resources/download-api-specifications/) specification. It also includes an OAuth 2.0 server for your particular needs.

Installing globally via `npm`:

```
npm install -g csc-server
```

## Prerequistes

1. Install Mongodb from [mongodb.com](https://www.mongodb.com/download-center/community)
2. Install [OpenSC](https://github.com/OpenSC/OpenSC/releases) that is needed for interacting with the SoftHSMv2 dll module. We will use `pkcs11-tool` exe.

3. Install [SoftHSMv2](https://github.com/opendnssec/SoftHSMv2) or just copy it from the project's [release binaries](https://github.com/simionrobert/cloud-signature-consortium/releases) to the resources folder.

- Set environment variabile `SOFTHSM2_CONF=%path_to_softhsm2\lib\softhsm2.conf%`
- In the file path\to\softhsm2.conf, set `directories.tokendir=%path_to_softhsm2\tokens_folder%`
- Initialize a new softhsm2 token with `%path_to_softhsm2\bin\softhsm2-util.exe%`

```
softhsm2-util --init-token --slot 0 --label "mytoken"
```

4. Install [OpenSSL](https://github.com/openssl/openssl) or just copy it from the project's [release binaries](https://github.com/simionrobert/cloud-signature-consortium/releases) to the resources folder.

- Generate a new certificate and private key for your https/SSL/TLS service and put them in the resources folder of the application (the one provided in config.json. See point 5):

```
openssl req -x509 -newkey rsa:4096 -keyout keySSL.pem -out certSSL.pem -days 365
```

In the [release version](https://github.com/simionrobert/cloud-signature-consortium/releases) you will find the following binaries:

- OpenSSL 1.1.1.d x86 (used by the app)
- SoftHSMv2 (used by the app)
- PKCS11Admin - 0.5.0 (Optional GUI to help you see the token objects)

5. Configure the service settings. See [Configuration](#configuration).

After you successfully installed and configured all the prerequistes, you can proceed to [Usage](#usage).

## Usage

Create your own user:

```
csc-server --createUser --user="username" --pass="password" --pin="pin"

```

If you plan to use OAuth 2.0, create your own client:

```
csc-server --createClient --name=name --id=id --secret=secret --redirectUri=redirectUri
```

Start CSC Server:

```
csc-server -l
```

Now you have a fully functional CSC server.

## Example Usage

```
Usage:
   csc-server [options]

Options:
  --createUser    Create a user using the arguments below.
       --user           Username of the user.
       --pass           Password of the user.
       --pin            PIN associated with the generated private key.

  --createClient  Create an OAuth 2.0 client using the arguments below.
       --name          Name of the client application.
       --id            Client id.',
       --secret        Client_secret.
       --redirectUri   Redirect_uri.

  --listen, -l     Start the server
       --silent, -s     Suppress log messages from output.

  --version, -v    Print the version and exit.
  --help, -h       Print this list and exit.
Examples
   csc-server -l
   csc-server --createUser --user=username --pass=password --pin=pin
   csc-server --createClient --name=name --id=id --secret=secret --redirectUri=redirectUri
```

## Configuration

The configuration file is located at `%userprofile%/AppData/Roaming/npm/node_modules/csc-server/config/config.json`.
Feel free to customize and provide the correct paths of the software you installed in the [Prerequistes](#prerequistes).

```
{
    "version": "1.0.2",
    "csc": {
        "access_token_expiring_time": 3600,
        "refresh_token_expiring_time": 7200,
        "sad_expiring_time": 1800,
        "code_expiring_time": 600,
        "otp_expiring_time": 1800,
        "max_results": 10
    },
    "https": {
        "host": "0.0.0.0",
        "port": "8080",
        "certificate": "D:/Scoala/Dizertatie/CSC Framework/resources/certSSL.pem",
        "private_key": "D:/Scoala/Dizertatie/CSC Framework/resources/keySSL.pem",
        "private_key_password": "0000"
    },
    "database_url": "mongodb://localhost:27017/csc",
    "resources_path": "D:/Scoala/Dizertatie/CSC Framework/resources",
    "softhsm2_driver_path": "D:/Scoala/Dizertatie/CSC Framework/utils/SoftHSMv2/lib/softhsm2.dll",
    "openSSL_path": "D:/Scoala/Dizertatie/CSC Framework/utils/openssl-1.1.1-x86/openssl.exe",
    "openSC_path": "C:/Program Files (x86)/OpenSC Project/OpenSC/tools/pkcs11-tool.exe",
    "token": {
        "slot": "189467408",
        "pin": "0000"
    }
}
```

You can also configure the endpoint `/csc/v1/info` results in the `%userprofile%/AppData/Roaming/npm/node_modules/csc-server/config/info.json` configuration file.

```
{
    "specs": "1.0.3.0",
    "name": "CSC Provider",
    "logo": "https://service.domain.org/images/logo.png",
    "region": "RO",
    "lang": "en-US",
    "description": "An efficient remote signature service",
    "authType": [
            "basic",
            "oauth2code"
    ],
    "oauth2": "https://www.domain.org/",
    "methods": [
            "auth/login",
            "auth/revoke",
            "credentials/list",
            "credentials/info",
            "credentials/authorize",
            "credentials/sendOTP",
            "signatures/signHash"
    ]
}
```

## Authors

- **Simion Robert George** - [simionrobert](https://github.com/simionrobert)

See also the list of [contributors](https://github.com/simionrobert/CSC-Framework/contributors) who participated in this project.

I really appreciate all kinds of feedback and contributions.

**Aditional notes:**
If you have some issues referring parts of code in the master branch add them in the issues section.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

---
_Source: https://npm.io/package/csc-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
