Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

citi-oauth

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

citi-oauth - npm Package Compare versions

Comparing version 0.2.2 to 1.0.0

.github/FUNDING.yml

17

lib/index.d.ts

@@ -0,1 +1,2 @@

import CitiReward from './reward';
interface ILogger {

@@ -13,2 +14,5 @@ warn: (...args: any[]) => void;

scope: string;
token_type?: string;
consented_on?: number;
refresh_token_expires_in?: number;
}

@@ -21,2 +25,5 @@ export declare class AccessToken implements IAccessToken {

readonly scope: string;
readonly token_type: string | undefined;
readonly consented_on: number | undefined;
readonly refresh_token_expires_in: number | undefined;
constructor(data: IAccessToken);

@@ -26,4 +33,5 @@ isValid(): boolean;

export default class CitiOAuth {
readonly getToken: (openId: string) => any;
private readonly appId;
Reward: CitiReward;
readonly getToken: (openId?: string) => any;
readonly appId: string;
private readonly appSecret;

@@ -34,5 +42,7 @@ private readonly saveToken;

private readonly redirectUri;
constructor(appId: string, appSecret: string, redirectUri: string, saveToken?: (openid: string, token: object) => void, getToken?: (openId: string) => any, logger?: ILogger);
endpoint: string;
constructor(appId: string, appSecret: string, redirectUri: string, saveToken?: (openid: string, token: object) => void, getToken?: (openId?: string) => any, logger?: ILogger);
getAuthorizeURL(state?: string, scope?: string, countryCode?: string): string;
getAccessToken(code: string, countryCode?: string): Promise<AccessToken>;
getClientAccessToken(countryCode?: string, scope?: string): Promise<AccessToken>;
refreshAccessToken(refreshToken: string): Promise<AccessToken>;

@@ -42,3 +52,4 @@ getUserByAccessToken(accessToken: string): Promise<any>;

private processAccessToken;
wrap(requestFunc: (url: string, data?: any, options?: any) => Promise<any>): (url: string, data?: any, options?: any) => Promise<any>;
}
export {};

38

lib/index.js

@@ -5,14 +5,8 @@ "use strict";

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = __importDefault(require("axios"));
const querystring = __importStar(require("querystring"));
const querystring_1 = __importDefault(require("querystring"));
const v4_1 = __importDefault(require("uuid/v4"));
const util_1 = require("./util");
const reward_1 = __importDefault(require("./reward"));
function getAuthorizeURL(parameters) {

@@ -30,3 +24,3 @@ const { redirect, scope, state, url, appId, countryCode } = parameters;

};
return url + '?' + querystring.stringify(info);
return url + '?' + querystring_1.default.stringify(info);
}

@@ -40,2 +34,5 @@ class AccessToken {

this.scope = data.scope;
this.token_type = data.token_type;
this.consented_on = data.consented_on;
this.refresh_token_expires_in = data.refresh_token_expires_in;
Object.keys(data).map(k => (this[k] = data[k]));

@@ -58,3 +55,3 @@ }

? (openId) => {
return this.store[openId];
return this.store[openId || ''];
}

@@ -70,2 +67,4 @@ : getToken;

}
this.endpoint = 'https://sandbox.apihub.citi.com/gcb/api';
this.Reward = new reward_1.default(this);
}

@@ -94,2 +93,10 @@ getAuthorizeURL(state, scope, countryCode = 'sg') {

}
async getClientAccessToken(countryCode = 'sg', scope = '/api') {
const url = `/clientCredentials/oauth2/token/${countryCode}/gcb`;
const info = {
grant_type: 'client_credentials',
scope
};
return this.processAccessToken(url, info);
}
async refreshAccessToken(refreshToken) {

@@ -119,5 +126,5 @@ const url = 'https://sandbox.apihub.citi.com/gcb/api/authCode/oauth2/refresh';

}
async processAccessToken(url, info) {
async processAccessToken(url, info, options) {
const time = new Date().getTime();
const tokenResult = await util_1.wrapper(axios_1.default.post)(url, querystring.stringify(info), {
const tokenResult = await util_1.wrapper(axios_1.default.post, { endpoint: this.endpoint })(url, querystring_1.default.stringify(info), Object.assign({
headers: {

@@ -128,3 +135,3 @@ Accept: 'application/json',

},
});
}, options));
const accessToken = new AccessToken(Object.assign({ created_at: time }, tokenResult));

@@ -139,4 +146,7 @@ try {

}
wrap(requestFunc) {
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const wrapper: (requestFunc: (url: string, data?: any, options?: object | undefined) => Promise<any>) => (url: string, data?: any, options?: object | undefined) => Promise<any>;
export declare const wrapper: (requestFunc: (url: string, data?: any, options?: any) => Promise<any>, settings?: any) => (url: string, data?: any, options?: any) => Promise<any>;

@@ -9,6 +9,6 @@ "use strict";

}
exports.wrapper = (requestFunc) => {
exports.wrapper = (requestFunc, settings) => {
return async (url, data, options) => {
try {
const { data: res } = await requestFunc(url, data, options);
const { data: res } = await requestFunc(url.startsWith('http') ? url : `${settings.endpoint}${url}`, data, options);
if (res.errcode) {

@@ -24,2 +24,4 @@ const error = new CitiAPIError(res.errmsg);

console.error('碰到了错误!');
err.request = {};
err.response = { data: err.response.data };
console.error(err);

@@ -33,2 +35,2 @@ if (!(err instanceof CitiAPIError)) {

};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsTUFBTSxZQUFhLFNBQVEsS0FBSztJQUk5QixZQUFZLEdBQVc7UUFDckIsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBRVYsSUFBSSxDQUFDLElBQUksR0FBRyxjQUFjLENBQUE7SUFDNUIsQ0FBQztDQUNGO0FBRVksUUFBQSxPQUFPLEdBQUcsQ0FBQyxXQUF3RSxFQUFFLEVBQUU7SUFDbEcsT0FBTyxLQUFLLEVBQUUsR0FBVyxFQUFFLElBQVUsRUFBRSxPQUFnQixFQUFFLEVBQUU7UUFDekQsSUFBSTtZQUNGLE1BQU0sRUFBRSxJQUFJLEVBQUUsR0FBRyxFQUFFLEdBQUcsTUFBTSxXQUFXLENBQUMsR0FBRyxFQUFFLElBQUksRUFBRSxPQUFPLENBQUMsQ0FBQTtZQUUzRCxJQUFJLEdBQUcsQ0FBQyxPQUFPLEVBQUU7Z0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QUFHLFNBQVMsR0FBRyxHQUFHLENBQUMsSUFBSSxDQUFBO2FBQ2hDO1lBRUQsTUFBTSxHQUFHLENBQUE7U0FDVjtJQUNILENBQUMsQ0FBQTtBQUNILENBQUMsQ0FBQSJ9
{
"name": "citi-oauth",
"version": "0.2.2",
"version": "1.0.0",
"description": "citi oauth typescript version",

@@ -11,10 +11,12 @@ "main": "lib/index.js",

"scripts": {
"test": "TS_NODE_TRANSPILE_ONLY=1 mocha --require espower-typescript/guess --timeout 3000 --exit 'src/test/*.test.ts'",
"test": "TS_NODE_TRANSPILE_ONLY=1 mocha --require espower-typescript/guess --timeout 10000 --exit 'src/test/*.test.ts'",
"test:coverage": "TS_NODE_COMPILER_OPTIONS='{\"target\":\"es6\"}' nyc npm test",
"build": "tsc -p tsconfig.json",
"prepare": "npm run build"
"prepare": "npm run build",
"semantic-release": "semantic-release",
"postinstall": "echo \"Thank you for using citi-oauth!\n\nThe project needs your help! Please consider supporting of citi-oauth on Patreon:\n> https://www.patreon.com/jeff_tian\""
},
"repository": {
"type": "git",
"url": "git@github.com:Jeff-Tian/citi-oauth.git"
"url": "https://github.com/Jeff-Tian/citi-oauth"
},

@@ -48,3 +50,4 @@ "author": "jeff.tian@outlook.com",

"typemoq": "latest",
"typescript": "^3.3.3"
"typescript": "^3.3.3",
"semantic-release": "^15.13.30"
},

@@ -51,0 +54,0 @@ "types": "lib/index.d.ts",

@@ -19,2 +19,4 @@ # cit-oauth

- 获取基本信息
- 获取积分余额
- 充积分

@@ -21,0 +23,0 @@ 详细参见 [API 文档](https://sandbox.developerhub.citi.com/api/)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc