# wrap-gyazo

> Gyazo uploader made in TypeScript.

Latest version **1.0.3** (published 2022-01-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install wrap-gyazo
pnpm add wrap-gyazo
yarn add wrap-gyazo
bun add wrap-gyazo
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-01-06 |
| First published | 2022-01-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 (+24 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | s-n-1-0 |
| Maintainers | sn-10 |

## Links

- npm: https://www.npmjs.com/package/wrap-gyazo
- Repository: https://github.com/s-n-1-0/wrap-gyazo
- Homepage: https://github.com/s-n-1-0/wrap-gyazo#readme
- Issues: https://github.com/s-n-1-0/wrap-gyazo/issues
- npm.io page: https://npm.io/package/wrap-gyazo

## Dependencies (4)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [axios](https://npm.io/package/axios.md) ^0.24.0
- [form-data](https://npm.io/package/form-data.md) ^4.0.0
- [urlsafe-base64](https://npm.io/package/urlsafe-base64.md) ^1.0.0

## Recent versions

- 1.0.3 (latest) — 2022-01-06
- 1.0.2 — 2022-01-01
- 1.0.1 — 2022-01-01
- 1.0.0 — 2022-01-01

## README

# wrap-gyazo
Gyazo API wrapper made in TypeScript.  
*For now, only upload feature.


## Installation
`
npm i wrap-gyazo
`

## Register an application with Gyazo.
+ [Gyazo Applications](https://gyazo.com/oauth/applications)

## Authorize (Optional)
*If you want to get an access token for each user.

0. Get client_id, secret_id and Callback URL in [Gyazo Applications](https://gyazo.com/oauth/applications).
1. Generate a link for approval.  
```typescript
import {GyazoAdmin} from 'wrap-gyazo';
const gyazoAdmin = new GyazoAdmin({
  clientId:"***************",
  redirectUri:"***************",
  clientSecret:"***************"
});
const authUrl = gyazoAdmin.makeAuthorizeURL();
/**
 * authUrl = {url:string,state:string}
 */
```

【Optional】 Please use the "state" parameter to prevent CSRF.  
*The "state" parameter is uuidv4.  

2. The user accesses the generated URL and approves the app.
    1. Get the "code" and "state" parameters from the callback URL.
    2. 【Optional】 Check the state parameter.  
    3. Get "access_token" from "code".
    ```typescript
    const accessToken =  await gyazoAdmin.getAccessToken(code);
    ```

## Upload
### Preparation
1. Get the user access token or the [application access token](https://gyazo.com/oauth/applications).
2. Load an image data.

### Upload to Gyazo
```typescript
//base64
const uploadRes = await gyazoAdmin.uploadBase64(accessToken,base64);
//buffer
const uploadRes = await gyazoAdmin.uploadBuffer(accessToken,imageData,"png")
```
*You can't upload from a browser, because of the CORS policy

## Others
### File/Blob->Base64 Conversion (Browser Only)
```typescript
import {readAsDataURL} from 'wrap-gyazo';

const base64 = await readAsDataURL(file);
```
### Thanks for the Reference
+ [Gyazo API Docs](https://gyazo.com/api/docs)
+ [gyazo-api](https://github.com/shokai/node-gyazo-api)

### Pull Request
If you want to add a feature, please submit a pull request.

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