# secken-api

> Secken API SDK for Nodejs

Latest version **2.0.6** (published 2016-04-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install secken-api
pnpm add secken-api
yarn add secken-api
bun add secken-api
```

## 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 | 2.0.6 |
| Published | 2016-04-01 |
| First published | 2015-05-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+6 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Secken,Inc. |
| Maintainers | secbone |

## Links

- npm: https://www.npmjs.com/package/secken-api
- Repository: https://github.com/secken/secken-nodejs
- Homepage: https://github.com/secken/secken-nodejs#readme
- Issues: https://github.com/secken/secken-nodejs/issues
- npm.io page: https://npm.io/package/secken-api

## Dependencies (3)

- [q](https://npm.io/package/q.md) ^1.4.1
- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [request](https://npm.io/package/request.md) ^2.67.0

## Recent versions

- 2.0.6 (latest) — 2016-04-01
- 2.0.5 — 2016-01-16
- 2.0.4 — 2015-12-22
- 2.0.3 — 2015-08-14
- 2.0.2 — 2015-08-12
- 2.0.1 — 2015-08-12
- 2.0.0 — 2015-07-02
- 0.1.7 — 2015-06-11
- 0.1.6 — 2015-05-27
- 0.1.5 — 2015-05-22
- 0.1.4 — 2015-05-21
- 0.1.3 — 2015-05-20
- 0.1.2 — 2015-05-20
- 0.1.1 — 2015-05-20
- 0.1.0 — 2015-05-12

## README

# Secken SDK for Javascript

[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Downloads][downloads-image]][downloads-url]

## Install
```sh
npm install secken-api
```
## Usage


### require && config

```javascript
var Secken = require("secken-api");

var sk = new Secken({
    app_id: "",
    app_key: "",
    auth_id: ""
});
```
After initialization, Secken-api can help you to develop you project.
Most of Secken-api's functions will return a promise object which using `q`, then you can use the primose object embed into you project.

### Get Bind Qrcode Image Url
```javascript
sk.getBind({
    auth_type: 2,
    callback: "http://www.callback/path"
})
.then(function(result) {
    // Success
    var qrcodeURL = result.qrcode_url;
    console.log("this is qrcode:", qrcodeURL);
    // do some things

    return sk.getResult(result.event_id);
}, function(result) {
    // Failed
    var errorCode = result.status;

    // do some things

    return sk.breakQ();
}).then(success, failed, notify);
```

### Get Auth Qrcode Image Url
```javascript
sk.getAuth({
    auth_type: 3,
    callback: "http://www.callback/path"
})
.then(function(result) {
    // Success
    var qrcodeURL = result.qrcode_url;
    console.log("this is qrcode:", qrcodeURL);
    // do some things

    return sk.getResult(result.event_id);
}, function(result) {
    // Failed
    var errorCode = result.status;

    // do some things

    return sk.breakQ();
}).then(success, failed, notify);
```

### Realtime Auth
```javascript
sk.realtimeAuth({
    action_type: 1,
    uid: " user id ",
}).then(function(data) {
    // Success

    // do some things

    return sk.getResult(data.event_id);
}, function(data) {
    return sk.breakQ();
}).then(success, failed, notify);
```

### Get Result
```javascript
sk.getResult(event_id, time)
.then(function(data) {
    // Success
    console.log(data);

    // do some things
}, function(data) {
    // Failed

});
```
This function will repeat getting result, the default delay time is `1000` ms, you can use parameter `time` to set the delay time, and you can use the primose's `notify` function to get each response.
If you pass `false` as the value of `time`, it will run only once.

### Offline Auth
```javascript
sk.offlineAuth({
    dynamic_code: " code ",
    uid: " user id ",
}).then(function(data) {
    // Success

    // do some things

}, function(data) {});
```

### Get Auth Page Url
```javascript
var url = sk.authPage( " callback url " );
```

### Get Signature
`getSignature(params [,ignore])`, pass an object type value for `params` and an array type value for `ignore`.
You can use this function to get the signature string of a params object.

```javascript
var signature = sk.getSignature(params, ['user_ip', 'username']);
```

## Change log

#### 2.0.4
* use ES6
* change init params' key
* add `request()` function
* update `request` to 2.67.0

## Secken Team
[Secken](https://www.secken.com)


[npm-image]: https://img.shields.io/npm/v/secken-api.svg?style=flat-square
[npm-url]: https://npmjs.org/package/secken-api
[downloads-image]: http://img.shields.io/npm/dm/secken-api.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/secken-api
[travis-image]: https://img.shields.io/travis/secken/secken-nodejs.svg?style=flat-square
[travis-url]: https://travis-ci.org/secken/secken-nodejs

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