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 1.0.1 to 1.1.0

.nyc_output/cb04c134-e554-4041-b3ba-b9c20c6aedbf.json

2

lib/index.d.ts
import CitiReward from './reward';
import CitiCards from './cards';
interface ILogger {

@@ -40,2 +41,3 @@ warn: (...args: any[]) => void;

endpoint: string;
Cards: CitiCards;
constructor(appId: string, appSecret: string, redirectUri: string, saveToken?: (openid: string, token: object) => void, getToken?: (openId?: string) => any, logger?: ILogger);

@@ -42,0 +44,0 @@ getAuthorizeURL(state?: string, scope?: string, countryCode?: string): string;

52

lib/index.js

@@ -11,2 +11,3 @@ "use strict";

const reward_1 = __importDefault(require("./reward"));
const cards_1 = __importDefault(require("./cards"));
function getAuthorizeURL(parameters) {

@@ -17,3 +18,4 @@ const { redirect, scope, state, url, appId, countryCode } = parameters;

client_id: appId,
scope: scope || 'pay_with_points',
scope: scope ||
'pay_with_points accounts_details_transactions customers_profiles payees personal_domestic_transfers internal_domestic_transfers external_domestic_transfers bill_payments cards onboarding reference_data',
countryCode: (countryCode || 'sg').toUpperCase(),

@@ -41,3 +43,3 @@ businessCode: 'GCB'.toUpperCase(),

const time = new Date().getTime();
return !!this.access_token && time < this.created_at + this.expires_in * 1000;
return (!!this.access_token && time < this.created_at + this.expires_in * 1000);
}

@@ -58,3 +60,4 @@ }

: getToken;
if (!saveToken && (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'prod')) {
if (!saveToken &&
(process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'prod')) {
this.logger.warn(`Please don't save oauth token into memory under production!`);

@@ -69,2 +72,3 @@ }

this.Reward = new reward_1.default(this);
this.Cards = new cards_1.default(this);
}

@@ -94,7 +98,4 @@ 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
};
const url = `/clientCredentials/oauth2/token/${countryCode.toLowerCase()}/gcb`;
const info = { grant_type: 'client_credentials', scope };
return this.processAccessToken(url, info);

@@ -104,11 +105,10 @@ }

const url = 'https://sandbox.apihub.citi.com/gcb/api/authCode/oauth2/refresh';
const info = {
grant_type: 'refresh_token',
refresh_token: refreshToken,
};
const info = { grant_type: 'refresh_token', refresh_token: refreshToken };
return this.processAccessToken(url, info);
}
async getUserByAccessToken(accessToken) {
const url = 'https://sandbox.apihub.citi.com/gcb/api/v1/customers/profiles';
return util_1.wrapper(axios_1.default.get)(url, {
const url = '/v1/customers/profiles';
return util_1.wrapper(axios_1.default.get, {
endpoint: this.endpoint,
})(url, {
headers: {

@@ -125,3 +125,10 @@ Accept: 'application/json',

const accessToken = await this.getAccessToken(code, countryCode);
return this.getUserByAccessToken(accessToken.access_token);
const res = await this.getUserByAccessToken(accessToken.access_token);
try {
this.saveToken(res.emails && res.emails ? res.emails[0].emailAddress : '', accessToken);
}
catch (ex) {
this.logger.error('error = ', ex);
}
return res;
}

@@ -137,16 +144,11 @@ async processAccessToken(url, info, options) {

}, options));
const accessToken = new AccessToken(Object.assign({ created_at: time }, tokenResult));
try {
this.saveToken(tokenResult.openid, accessToken);
}
catch (e) {
this.logger.error(e);
}
return accessToken;
return new AccessToken(Object.assign({ created_at: time }, tokenResult));
}
wrap(requestFunc) {
return util_1.wrapper(requestFunc, { endpoint: this.endpoint });
return util_1.wrapper(requestFunc, {
endpoint: this.endpoint,
});
}
}
exports.default = CitiOAuth;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs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-15,2 +15,4 @@ # cit-oauth

[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=Jeff-Tian_citi-oauth)](https://sonarcloud.io/dashboard?id=Jeff-Tian_citi-oauth)
## 功能列表

@@ -21,2 +23,3 @@

- 获取积分余额
- 获取卡片列表
- 充积分

@@ -66,3 +69,3 @@

fs.writeFile(openid + ':access_token.txt', JSON.stringify(token), callback)
},
}
)

@@ -90,3 +93,3 @@ ```

TokenSchema.statics.getToken = function(openid, cb) {
this.findOne({ openid: openid }, function(err, result) {
this.findOne({openid: openid}, function(err, result) {
if (err) throw err

@@ -103,4 +106,4 @@ return cb(null, result)

// 有则更新,无则添加
var query = { openid: openid }
var options = { upsert: true }
var query = {openid: openid}
var options = {upsert: true}
this.update(query, token, options, function(err, result) {

@@ -129,3 +132,3 @@ if (err) throw err

Token.setToken(openid, token, callback)
},
}
)

@@ -174,7 +177,14 @@ ```

'REPLACE INTO token(access_token, expires_in, refresh_token, openid, scope, create_at) VALUES(?, ?, ?, ?, ?, ?)'
var fields = [token.access_token, token.expires_in, token.refresh_token, token.openid, token.scope, token.create_at]
var fields = [
token.access_token,
token.expires_in,
token.refresh_token,
token.openid,
token.scope,
token.create_at,
]
db.query(sql, fields, function(err, result) {
return callback(err)
})
},
}
)

@@ -181,0 +191,0 @@ ```

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