# corekey

> A simply Misskey library for Node.js

Latest version **1.0.0** (published 2020-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install corekey
pnpm add corekey
yarn add corekey
bun add corekey
```

## 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.0 |
| Published | 2020-01-17 |
| First published | 2019-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Marihachi |
| Maintainers | marihachi |

## Links

- npm: https://www.npmjs.com/package/corekey
- Repository: https://github.com/marihachi/corekey
- Homepage: https://github.com/marihachi/corekey#readme
- Issues: https://github.com/marihachi/corekey/issues
- npm.io page: https://npm.io/package/corekey

## Dependencies (3)

- [cafy](https://npm.io/package/cafy.md) 15.2.x
- [form-data](https://npm.io/package/form-data.md) 3.0.x
- [node-fetch](https://npm.io/package/node-fetch.md) 2.6.x

## Recent versions

- 1.0.0 (latest) — 2020-01-17
- 1.0.0-beta.6 — 2019-05-25
- 1.0.0-beta.5 — 2019-05-24
- 1.0.0-beta.4 — 2019-05-10
- 1.0.0-beta.3 — 2019-05-10
- 1.0.0-beta.2 — 2019-05-10
- 1.0.0-beta.1 — 2019-05-10

## README

# corekey
A simply Misskey library for Node.js

## Installation
```
npm i corekey
```

## Usage
### 1. Import the corekey library
You need to import classes you want to use.
```ts
import {
	App,
	AuthSession
} from 'corekey';
```

### 2. Create a Misskey App
You can create a Misskey App in App.create static method.
```ts
const app = await App.create('misskey.io', 'example app', 'generated by corekey', ['write:notes']);
```

### 3. Start a session of the app authorization
Let's get your account instance!
```ts
const session = await AuthSession.generate(app);
console.log('open in your browser: ', session.url);

const account = await session.waitForAuth();
```

### 4. Access various APIs
For example, you can post your notes to the Misskey.
```ts
await account.request('notes/create', {
	text: 'corekey test'
});
```

You can also upload binary data. Let's upload files to your drive!
```ts
await account.requestBinary('drive/files/create', {
	force: true,
	file: fs.createReadStream('picture.jpg');
});
```

Note: If you use `await`, you need to wrap the statement with Async Function.

Enjoy!

## Other features
### Configuration of requester
The requesters provide processing of API request.
You can define and set a custom-requester to the `Configuration.Requester`.
The requester needs to implement the `IRequester` interface.
The default value of `Configuration.Requester` is `FetchRequester`.
`FetchRequester` fetches the API execution result by using the Fetch API.

e.g.
```ts
Configuration.Requester = new StubRequester();
```

### Version acquisition of Misskey instance
You may need to get the version of Misskey instance when authorization of a Misskey App.  
You can get version of Misskey instance as follows:
```ts
const version: string = await Server.getVersion('misskey.io');
```
Note that you need to import `Server` class from the corekey.

## License
MIT

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