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

next-auth-zbd-provider

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-auth-zbd-provider - npm Package Compare versions

Comparing version 0.3.7 to 0.3.8

48

index.d.ts
export declare const getZBDProvider: ({ clientId, clientSecret, apiKey, scope, }: {
clientId: string;
clientSecret: string;
apiKey: string;
scope: string;
}) => {
id: string;
name: string;
type: string;
clientId: string;
clientSecret: string;
authorization: {
url: string;
params: {
scope: string;
};
};
token: string;
checks: string[];
userinfo: {
request(context: any): Promise<{}>;
};
profile(profile: any): {
id: any;
email: any;
gamertag: any;
image: any;
isVerified: any;
lightningAddress: any;
publicBio: any;
publicStaticCharge: any;
social: any;
balance: any;
remainingAmountLimits: any;
};
style: {
logo: string;
logoDark: string;
bg: string;
text: string;
bgDark: string;
textDark: string;
};
};
clientId: string | any;
clientSecret: string | any;
apiKey: string | any;
scope: string | any;
}) => any;

219

index.js

@@ -18,113 +18,116 @@ "use strict";

const ZBD_DEFAULT_SCOPES = 'user,wallet';
const getZBDProvider = ({ clientId, clientSecret, apiKey, scope = ZBD_DEFAULT_SCOPES, }) => ({
id: "zbd",
name: "ZBD",
type: "oauth",
clientId,
clientSecret,
authorization: {
url: ZBD_AUTH_URL,
params: { scope: scope }
},
token: ZBD_TOKEN_URL,
checks: ["pkce", "state"],
userinfo: {
request(context) {
return __awaiter(this, void 0, void 0, function* () {
// Default empty user wallet obj
const emptyUserWallet = {
"balance": null,
"remainingAmountLimits": {
"daily": null,
"maxCredit": null,
"monthly": null,
"weekly": null,
const getZBDProvider = ({ clientId, clientSecret, apiKey, scope = ZBD_DEFAULT_SCOPES, }) => {
const provider = {
id: "zbd",
name: "ZBD",
type: "oauth",
clientId,
clientSecret,
authorization: {
url: ZBD_AUTH_URL,
params: { scope: scope }
},
token: ZBD_TOKEN_URL,
checks: ["pkce", "state"],
userinfo: {
request(context) {
return __awaiter(this, void 0, void 0, function* () {
// Default empty user wallet obj
const emptyUserWallet = {
"balance": null,
"remainingAmountLimits": {
"daily": null,
"maxCredit": null,
"monthly": null,
"weekly": null,
}
};
// Default empty user profile obj
const emptyUserProfile = {
"id": null,
"email": null,
"gamertag": null,
"image": null,
"isVerified": null,
"lightningAddress": null,
"publicBio": null,
"publicStaticCharge": null,
"social": {},
};
const headers = {
apikey: apiKey,
};
if (context.tokens.access_token) {
headers['usertoken'] = context.tokens.access_token;
}
};
// Default empty user profile obj
const emptyUserProfile = {
"id": null,
"email": null,
"gamertag": null,
"image": null,
"isVerified": null,
"lightningAddress": null,
"publicBio": null,
"publicStaticCharge": null,
"social": {},
};
const headers = {
apikey: apiKey,
};
if (context.tokens.access_token) {
headers['usertoken'] = context.tokens.access_token;
}
;
if (!headers['usertoken']) {
console.log('No access_token was found from the response of authorization request.');
return Object.assign(Object.assign({}, emptyUserProfile), emptyUserWallet);
}
;
// Fetching user profile and wallet data in parallel
const t = yield fetch(ZBD_USER_DATA_URL, {
headers,
;
if (!headers['usertoken']) {
console.log('No access_token was found from the response of authorization request.');
return Object.assign(Object.assign({}, emptyUserProfile), emptyUserWallet);
}
;
// Fetching user profile and wallet data in parallel
const t = yield fetch(ZBD_USER_DATA_URL, {
headers,
});
const d = yield fetch(ZBD_WALLET_DATA_URL, {
headers,
});
// Handling response from both fetches
let all = {};
if (t.ok) {
const p = yield t.json();
all = Object.assign({}, p.data);
}
else {
console.log(`Response from ${ZBD_USER_DATA_URL} resulted in the following:`);
console.log('Status Code:', t.status);
console.log('Response Text:', t.statusText);
all = Object.assign({}, emptyUserProfile);
}
;
if (d.ok) {
const p = yield d.json();
all = Object.assign(Object.assign({}, all), p.data);
}
else {
console.log(`Response from ${ZBD_WALLET_DATA_URL} resulted in the following:`);
console.log('Status Code:', t.status);
console.log('Response Text:', t.statusText);
all = Object.assign(Object.assign({}, all), emptyUserWallet);
}
;
// Returning all data
return all;
});
const d = yield fetch(ZBD_WALLET_DATA_URL, {
headers,
});
// Handling response from both fetches
let all = {};
if (t.ok) {
const p = yield t.json();
all = Object.assign({}, p.data);
}
else {
console.log(`Response from ${ZBD_USER_DATA_URL} resulted in the following:`);
console.log('Status Code:', t.status);
console.log('Response Text:', t.statusText);
all = Object.assign({}, emptyUserProfile);
}
;
if (d.ok) {
const p = yield d.json();
all = Object.assign(Object.assign({}, all), p.data);
}
else {
console.log(`Response from ${ZBD_WALLET_DATA_URL} resulted in the following:`);
console.log('Status Code:', t.status);
console.log('Response Text:', t.statusText);
all = Object.assign(Object.assign({}, all), emptyUserWallet);
}
;
// Returning all data
return all;
});
},
},
},
profile(profile) {
return {
// User profile properties
"id": profile['id'],
"email": profile['email'],
"gamertag": profile['gamertag'],
"image": profile['image'],
"isVerified": profile['isVerified'],
"lightningAddress": profile['lightningAddress'],
"publicBio": profile['publicBio'],
"publicStaticCharge": profile['publicStaticCharge'],
"social": profile['social'],
// User wallet properties
"balance": profile['balance'],
"remainingAmountLimits": profile['remainingAmountLimits'],
};
},
style: {
logo: "https://cdn.zebedee.io/zbdgg/social/zbd-pfp-default.png",
logoDark: "https://cdn.zebedee.io/zbdgg/social/zbd-pfp-default.png",
bg: "#fff",
text: "#000",
bgDark: "#000",
textDark: "#fff",
},
});
profile(profile) {
return {
// User profile properties
"id": profile['id'],
"email": profile['email'],
"gamertag": profile['gamertag'],
"image": profile['image'],
"isVerified": profile['isVerified'],
"lightningAddress": profile['lightningAddress'],
"publicBio": profile['publicBio'],
"publicStaticCharge": profile['publicStaticCharge'],
"social": profile['social'],
// User wallet properties
"balance": profile['balance'],
"remainingAmountLimits": profile['remainingAmountLimits'],
};
},
style: {
logo: "https://cdn.zebedee.io/zbdgg/social/zbd-pfp-default.png",
logoDark: "https://cdn.zebedee.io/zbdgg/social/zbd-pfp-default.png",
bg: "#fff",
text: "#000",
bgDark: "#000",
textDark: "#fff",
},
};
return provider;
};
exports.getZBDProvider = getZBDProvider;
{
"name": "next-auth-zbd-provider",
"version": "0.3.7",
"version": "0.3.8",
"description": "NextAuth.js provider for ZBD OAuth2",

@@ -5,0 +5,0 @@ "main": "index.ts",

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