open-index/open-npm huggingface dataset:
npm package: @shareandcharge/ocn-notary
Description: Library for signing requests and verifying signatures on the Open Charging Network
Author: Share&Charge Foundation
Latest version: 1.0.0

# OCN Notary JavaScript Package

This readme contains specific information pertaining to the JavaScript package of the Open Charging Network
Notary, including: how to test, build, publish, install and use.

This package is written in TypeScript to provide type definitions for developers.

## Install

```
npm install @shareandcharge/ocn-notary
```

## Usage

### Signing a request:

First, create a request object containing the headers, url-encoded parameters and body of the OCPI request. 

```js
const Notary = require("@sharecharge/ocn-notary")

const request = {
    headers: {
        "X-Correlation-ID": "123"
        ...
    },
    body: {
        "id": "LOC1",
        ...
    }
}
```

Next, instantiate an empty notary object and sign the request with your Ethereum private key.

```js
const notary = new Notary()
await notary.sign(request, privateKey)
```

The `OCN-Signature` is a base64-encoded, JSON serialized string of the Notary. Retrieving it is possible with the Notary's serialize
method.

```js
const ocnSignature = notary.serialize()
console.log(ocnSignature)
// eyJmaWVsZHMiOlsiJFsnaGVhZGVycyddWyd4LWNvcnJlbGF0aW9uLWlkJ10iLCIkWydoZWFkZXJzJ11bJ...
```

This string should be appended to your headers with the key `OCN-Signature` before sending a request to the Open
Charging Network.

### Verifying a request:

In order to verify the request, first deserialize the `OCN-Signature` header received from a counterparty.

```js
const notary = Notary.deserialize(ocnSignature)
```

Then, call the verify method on the notary object with the headers, url-encoded parameters and body of the request
received (see above for how this looks like).

```js
const isValid = notary.verify(request)
console.log(isValid)
// true
```

### Modifying a request:

It might be the case that an OCN node needs to modify a request before forwarding it to the recipient, such as in 
the case where the sender has specified a `response_url`. In order to do this, we can stash the values that will be
changed:

```js
const notary = Notary.deserialize(ocnSignature)
notary.stash({
    "$['body']['response_url']": "https://amazing.msp.org/commands/START_SESSION/42"
})
```

It is important to sign the new request afterwards:

```js
await notary.sign(modifiedRequest, someOtherPrivateKey)
```

And finally, include the signature in the forwarded request by serializing the notary object:

```js
headers["OCN-Signature"] = notary.serialize()
```
npm package: @shareandcharge/settlement
Description: Share & Charge smart contracts pertaining to settlement of charging sessions
Author: Share & Charge foundation
Latest version: 0.1.4

Share&Charge Settlement Smart Contracts

![CircleCI](https://circleci.com/gh/motionwerkGmbH/sharecharge-contracts.svg?style=svg&circle-token=4894d650771ab05ec8efbc595c8e77e151784ac9)

Share&Charge eMobility smart contracts written in Solidity for Ethereum-based networks.

## Install

The contract definitions are available as an NPM package for programmatic access and usage:

```
npm install @shareandcharge/settlement
```

## Usage

The package provides a class `SnC` which simplifies the work with the smart-contracts. 
The constructor takes 3 parameters:
* stage - one of `local`, `poa`, `test` and `tobalaba`
* privateKey - the private key of the account you want to sign your transactions with
* provider - optionally you can override the default configuration for accessing the node by supplying your own provider

the packages uses [ethers](https://docs.ethers.io/ethers.js/html/) for communicating 
with the parity node. 

the SnC class provides access to the smart contracts in the form of instantiated objects which expose 
all the implemented functions. The available smart-contracts are:
* settlement - the wallet into which you have to send tokens in order for them to be used as payment
* eurToken - the EUR stable coin token
* usdToken - the USD stable coin token
* chfToken - the CHF stable coin token (only on Tobabala)
* at this stage we're not using the EVT token for staking. Hence its absence from the list

at this stage there are no faucets to get stable coins for test. Create an issue with your address and the environement on which you work and we'll send some tokens your way

once you have tokens you can provision your account in the Settlement contract by calling the `provision` function on the instantiated `SnC` object. 
That would look something like this:
```
snc.eurToken.provision(amount) // the amount must be a string and can be in scientific notation. e.g. 2.1e28
```

Once your account is provisioned, you can transfer the tokens by delegating the transaction to anyone. Get the signature by calling
```
getSignedTransferRaw(recipient: address, amount: string, currency: [EUR, USD, CHF or erc20 token address])
```

this signature can then be forwarded to a server which can submit it to the smart-contract without needing to know the signer's private key


## Development

Clone and install dependencies:

```
$ git clone https://bitbucket.org/shareandcharge/contracts.git
$ cd sharecharge-contracts
$ npm install
```

In two different terminal sessions, ensure the contracts are working as expected:

```
$ npm run ganache
$ npm test
```

Initial deployment of the smart contracts:

```
truffle migrate --network=<STAGE>
```

Publish contract definitions (<STAGE> defaults to "local"):

```
npm run publish-dev <STAGE>
```

The contract definitions are now available to be used in `./contract.defs.<STAGE>.json`.
npm package: @shareandcharge/sharecharge-contracts
Description: Share & Charge smart contracts
Author: Share & Charge foundation
Latest version: 0.10.30

Share&Charge Smart Contracts

![CircleCI](https://circleci.com/gh/motionwerkGmbH/sharecharge-contracts.svg?style=svg&circle-token=4894d650771ab05ec8efbc595c8e77e151784ac9)

Share&Charge eMobility smart contracts written in Solidity for Ethereum-based networks.

## Install

The contract definitions are available as an NPM package for programmatic access and usage:

```
npm install @shareandcharge/sharecharge-contracts
```

## Usage

The package provides a class `SnC` which simplifies the work with the smart-contracts. 
The constructor takes 3 parameters:
* stage - one of `local`, `poa`, `test` and `tobalaba`
* privateKey - the private key of the account you want to sign your transactions with
* provider - optionally you can override the default configuration for accessing the node by supplying your own provider

the packages uses [ethers](https://docs.ethers.io/ethers.js/html/) for communicating 
with the parity node. 

the SnC class provides access to the smart contracts in the form of instantiated objects which expose 
all the implemented functions. The available smart-contracts are:
* settlement - the wallet into which you have to send tokens in order for them to be used as payment
* eurToken - the EUR stable coin token
* usdToken - the USD stable coin token
* at this stage we're not using the EVT token for staking. Hence its absence from the list

at this stage there are no faucets to get stable coins for test. Create an issue with your address and the environement on which you work and we'll send some tokens your way

once you have tokens you can provision your account in the Settlement contract by calling the `provision` function on the instantiated `SnC` object. 
That would look something like this:
```
snc.eurToken.provision(amount) // the amount must be a string and can be in scientific notation. e.g. 2.1e28
```

Once your account is provisioned, you can transfer the tokens by delegating the transaction to anyone. Get the signature by calling
```
getSignedTransferRaw(recipient: address, amount: string, currency: [EUR, USD])
```

this signature can then be forwarded to a server which can submit it to the smart-contract without needing to know the signer's private key


## Development

Clone and install dependencies:

```
$ git clone https://github.com/motionwerkGmbH/sharecharge-contracts.git
$ cd sharecharge-contracts
$ npm install
```

In two different terminal sessions, ensure the contracts are working as expected:

```
$ npm run ganache
$ npm test
```

Initial deployment of the smart contracts:

```
truffle migrate --network=<STAGE>
```

Publish contract definitions (<STAGE> defaults to "local"):

```
npm run publish-dev <STAGE>
```

The contract definitions are now available to be used in `./contract.defs.<STAGE>.json`.
npm package: @shareandcharge/sharecharge-core-client
Description: Share & Charge Core Client for Charge Point Operators
Author: MotionWerk GmbH
Latest version: 0.15.2

# Share & Charge Core Client

The Core Client is used by Charge Point Operators and private Charge Point Owners to manage charge sessions on the Share & Charge e-Mobility Network.
It directly listens to Share & Charge smart contract events and filters based on EVSEs connected to a wallet configured by the user.  

## Quickstart

Install via NPM:
```
npm install -g @motionwerk/sharecharge-core-client
```

A default configuration file will be generated in `$HOME/.sharecharge/`. It is important to configure the Core Client to listen on a particular `stage` and `ethProvider` so that the correct contracts are used. Additionally, a funded wallet is necessary to add charge points to the network. These charge points will be filtered automatically by the Core Client, based on the provided wallet `seed` in the configuration file.

Running the `init` command will setup the Core Client to listen to the S&C test network.
```
sc-cc init
```

The wallet can be created and charge points added by using the Share & Charge command line interface:
```
npm install -g @motionwerk/sharecharge-cli
```

Create a wallet and follow the instructions to use:
```
sc-cli wallet create
```

Add charge points to the network:
```
sc-cli store add-locations
```

Add tariffs to the network:
```
sc-cli store add-tariffs
```

Finally, you can run the Core Client using:
```
sc-cc start
```

If all has been correctly configured you will be presented with the wallet's coinbase (primary address) and charge points upon start. 

#### Connecting a bridge

Bridges must implement the [`IBridge`](https://github.com/motionwerkGmbH/sharecharge-core-client/blob/develop/src/interfaces/iBridge.ts) interface.

An example bridge is provided for testing purposes and includes an autostop after 10 seconds.
npm package: @sharebravery/openapi
Description: 根据 [OpenApi3](https://swagger.io/blog/news/whats-new-in-openapi-3-0/) 文档生成 request 请求代码。
Latest version: 1.2.0

## 介绍

根据 [OpenApi3](https://swagger.io/blog/news/whats-new-in-openapi-3-0/) 文档生成 request 请求代码。

## 使用

```node
npm i --save-dev @sharebravery/openapi
```

在项目根目录新建 `openapi.config.ts`

```ts
const { generateService } = require('@sharebravery/openapi');

generateService({
  schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
  serversPath: './servers',
});
```

在 `package.json` 的 `script` 中添加 api: `"gen:api": "ts-node openapi.config.ts",`

生成 api

```node
npm run gen:api
```

## 参数

| 属性 | 必填 | 备注 | 类型 | 默认值 |
| --- | --- | --- | --- | --- |
| requestLibPath | 否 | 自定义请求方法路径 | string | - |
| requestImportStatement | 否 | 自定义请求方法表达式 | string | - |
| apiPrefix | 否 | api 的前缀 | string | - |
| serversPath | 否 | 生成的文件夹的路径 | string | - |
| schemaPath | 否 | Swagger 2.0 或 OpenAPI 3.0 的地址 | string | - |
| projectName | 否 | 项目名称 | string | - |
| namespace | 否 | 命名空间名称 | string | API |
| mockFolder | 否 | mock 目录 | string | - |
| enumStyle | 否 | 枚举样式 | string-literal \| enum | string-literal |
| nullable | 否 | 使用 null 代替可选 | boolean | false |
| dataFields | 否 | response 中数据字段 | string[] | - |
npm package: @sharebravery/wave-cli
Description: 集成便携开发工具解决方案
Author: sharebravery
Latest version: 1.0.3

# wave-cli 集成便携开发工具解决方案

- 集成符合Angular规范的commit
- OpenAPI To Typescript

# TODO
  
- [ ] 集成OpenAPI To Dart(Flutter)
- [ ] CHANGELOG
  
# 使用

安装：`npm install @sharebravery/wave-cli -g`

`wave -V`

# 初始化配置文件 init


`wave init`

# 规范化提交 commit

`wave commit`

`wave commit [msg]`

# 生成API
## OpenAPI To Typescript
`wave genapi:ts`