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

fbsdk-ts

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fbsdk-ts - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

4

dist/api-spec/index.d.ts
import Node, { CRUDNodeInfo, CRUDEdgeInfoSet } from './node';
import { AdAccount, AdNetworkAnalyticsAsyncQueryResult, Album, Application, ApplicationAppEventTypes, ApplicationPermission, ApplicationPermissionStatus, AppRequest, AsyncSession, Business, ButtonAutoDetectionDeviceSelection, CanvasAppAsset, Comment, CommerceMerchantSettings, ConversionConfig, CPASAdvertiserPartnershipRecommendation, CPASCollaborationRequest, CTCertDomain, DACheck, GamesIAPProduct, InsightsQueryResult, MobileSDKGK, Photo, ProductCatalog, Profile, ProfilePictureSource, Reaction, CommerceReturn, Role, SDKMLModel, TestAccount, Conversation, Message, Destination, Doc, Flight, FriendList, GroupDoc, GroupMessage, ImageCopyright, LeadGenData, UserLeadGenInfo, Link, LiveVideo, LiveVideoInputStream, LiveEncoder, User, Page, LiveVideoError, VideoPoll, MailingAddress, GroupFile, MediaFingerprint, NativeOffer, NativeOfferView, OfflineConversionDataSet, OfflineConversionDataSetUpload, CustomAudience, CustomConversion, OfflineConversionDataSetStats, CommerceMerchantTaxSettings, Video, Post, SignalsUploadProgress, GamesIAPOrder, PagePost, AssignedUser, AudioCopyright, CommerceMerchantSettingsSetupStatus, CommerceOrder, CommerceOrderTransactionDetail, CommercePayout, CustomUserSettings, InsightsResult, InstagramUser, InstantArticle, InstantArticleInsightsQueryResult, MessagingFeatureReview, MessengerProfile, PageCallToAction, PageSettings, PageThreadOwner, PageUserMessageThreadLabel, Persona, Recommendation, RTBDynamicPost, Tab, VideoCopyright, VideoCopyrightRule, VideoList, EventTour, Group, InsightBreakdown, BusinessUser, BusinessAssetGroup, Permission, UserIDForApp, AdStudy, PaymentEnginePayment, PaymentSubscription, UserIDForPage, AppRequestFormerRecipient } from '../graph-api/types';
import { AdAccount, AdNetworkAnalyticsAsyncQueryResult, Album, Application, ApplicationAppEventTypes, ApplicationPermission, ApplicationPermissionStatus, AppRequest, AsyncSession, Business, ButtonAutoDetectionDeviceSelection, CanvasAppAsset, Comment, CommerceMerchantSettings, ConversionConfig, CPASAdvertiserPartnershipRecommendation, CPASCollaborationRequest, CTCertDomain, DACheck, GamesIAPProduct, InsightsQueryResult, MobileSDKGK, Photo, ProductCatalog, Profile, ProfilePictureSource, Reaction, CommerceReturn, Role, SDKMLModel, TestAccount, Conversation, Message, Destination, Doc, Event, Flight, FriendList, GroupDoc, GroupMessage, ImageCopyright, LeadGenData, UserLeadGenInfo, Link, LiveVideo, LiveVideoInputStream, LiveEncoder, User, Page, LiveVideoError, VideoPoll, MailingAddress, GroupFile, MediaFingerprint, NativeOffer, NativeOfferView, OfflineConversionDataSet, OfflineConversionDataSetUpload, CustomAudience, CustomConversion, OfflineConversionDataSetStats, CommerceMerchantTaxSettings, Video, Post, SignalsUploadProgress, GamesIAPOrder, PagePost, AssignedUser, AudioCopyright, CommerceMerchantSettingsSetupStatus, CommerceOrder, CommerceOrderTransactionDetail, CommercePayout, CustomUserSettings, InsightsResult, InstagramUser, InstantArticle, InstantArticleInsightsQueryResult, MessagingFeatureReview, MessengerProfile, PageCallToAction, PageSettings, PageThreadOwner, PageUserMessageThreadLabel, Persona, Recommendation, RTBDynamicPost, Tab, VideoCopyright, VideoCopyrightRule, VideoList, EventTour, Group, InsightBreakdown, BusinessUser, BusinessAssetGroup, Permission, URL, UserIDForApp, AdStudy, PaymentEnginePayment, PaymentSubscription, UserIDForPage, AppRequestFormerRecipient } from '../graph-api/types';
interface NodeGetterTypeParams {

@@ -443,3 +443,3 @@ node: CRUDNodeInfo;

export declare type APISpecNodeCollection<T extends APISpec> = {
[node in keyof T]: (id?: string) => Node<T[node]['node'], T[node]['edges']>;
[node in keyof T]: (id: string) => Node<T[node]['node'], T[node]['edges']>;
};

@@ -446,0 +446,0 @@ export declare type NodeSpec<NodeType> = {

@@ -6,2 +6,5 @@ import { FacebookAppBase } from '../index';

export interface CRUDNodeInfo {
read_params?: {
[key: string]: any;
};
type: any;

@@ -11,11 +14,11 @@ create_params?: {

};
read_params?: {
[key: string]: any;
};
create_return?: any;
update_params?: {
[key: string]: any;
};
update_return?: any;
delete_params?: {
[key: string]: any;
};
delete_return?: any;
}

@@ -33,2 +36,3 @@ export interface CRUDEdgeInfo extends CRUDNodeInfo {

read: (...args: Parameters<CRUDNode<ThisEdge>['read']>) => Promise<EdgeResponse<DePromise<ReturnType<CRUDNode<ThisEdge>['read']>>>>;
create: (access_token: string, data: Partial<ThisEdge['type']>, params?: Partial<ThisEdge['create_params']>) => Promise<ThisEdge['create_return']>;
}

@@ -52,2 +56,3 @@ export default class Node<ThisNode extends CRUDNodeInfo, Edges extends CRUDEdgeInfoSet = any> implements CRUDNode<ThisNode> {

read: <FieldsTuple extends (keyof ThisEdge["type"])[]>(access_token: string, fields?: (keyof ThisEdge['type'])[], params?: DeepPartial<ThisEdge['read_params']>) => Promise<EdgeResponse<Pick<GraphAPIResponse<ThisEdge["type"]>, "id" | FieldsTuple[number]>>>;
create: (access_token: string, data: Partial<ThisEdge['type']>, params?: Partial<ThisEdge['create_params']>) => Promise<ThisEdge["create_return"]>;
}

@@ -54,0 +59,0 @@ interface EdgeResponse<NodeType> {

@@ -36,6 +36,11 @@ "use strict";

this.read = (access_token, fields, params) => __awaiter(this, void 0, void 0, function* () {
return this.GraphAPI.get(path_1.default.join(this.id, this.edge), Object.assign(Object.assign(params !== null && params !== void 0 ? params : {}, { access_token }), { fields: fields === null || fields === void 0 ? void 0 : fields.toString() }));
return this.GraphAPI.get(path_1.default.join(this.id, this.edge), Object.assign(Object.assign(params !== null && params !== void 0 ? params : {}, { access_token }), {
fields: fields === null || fields === void 0 ? void 0 : fields.toString(),
}));
});
this.create = (access_token, data, params) => __awaiter(this, void 0, void 0, function* () {
return this.GraphAPI.post(path_1.default.join(this.id, this.edge), data, Object.assign(params !== null && params !== void 0 ? params : {}, { access_token }));
});
}
}
exports.Edge = Edge;

@@ -12,5 +12,8 @@ import { AxiosInstance } from 'axios';

protected GraphAPI: {
get: <ReturnType_1, ParamsType = any>(endpoint: string, params?: ParamsType & {
get: <ReturnType_1, ParamsType = any>(endpoint: string, _params?: ParamsType & {
access_token: string;
}) => Promise<ReturnType_1>;
post: <ReturnType_2, DataType = any, ParamsType_1 = any>(endpoint: string, data: DataType, _params?: ParamsType_1 & {
access_token: string;
}) => Promise<ReturnType_2>;
};

@@ -17,0 +20,0 @@ protected abstract _Nodes: APISpecNodeCollection<API>;

@@ -38,2 +38,14 @@ "use strict";

const crypto_1 = __importDefault(require("crypto"));
const handleFacebookError = (e) => {
const { status, data } = e.response;
if (status.toString()[0] === '4') {
const _fbError = data.error;
const fbError = new Error();
fbError.message = _fbError.message;
fbError.name = _fbError.type;
throw fbError;
}
else
throw new Error('Unexpected error');
};
class FacebookAppBase {

@@ -43,7 +55,7 @@ constructor(config) {

this.GraphAPI = {
get: (endpoint, params) => __awaiter(this, void 0, void 0, function* () {
params = Object.assign(params, {
get: (endpoint, _params) => __awaiter(this, void 0, void 0, function* () {
const params = Object.assign(_params, {
appsecret_proof: crypto_1.default
.createHmac('sha256', this.config.appSecret)
.update(params.access_token)
.update(_params.access_token)
.digest('hex')

@@ -57,14 +69,21 @@ .toString(),

catch (e) {
const { status, data } = e.response;
if (status.toString()[0] === '4') {
const _fbError = data.error;
const fbError = new Error();
fbError.message = _fbError.message;
fbError.name = _fbError.type;
throw fbError;
}
else
throw new Error('Unexpected error');
handleFacebookError(e);
}
}),
post: (endpoint, data, _params) => __awaiter(this, void 0, void 0, function* () {
const params = Object.assign(_params, {
appsecret_proof: crypto_1.default
.createHmac('sha256', this.config.appSecret)
.update(_params.access_token)
.digest('hex')
.toString(),
});
try {
const response = ((yield this.graphAPIAxiosInstance.post(endpoint, data, { params })).data);
return response;
}
catch (e) {
handleFacebookError(e);
}
}),
};

@@ -71,0 +90,0 @@ }

{
"name": "fbsdk-ts",
"version": "1.0.1",
"version": "1.1.0",
"description": "Strongly-typed promise-based client library for Facebook's Graph API using TypeScript",

@@ -11,3 +11,2 @@ "main": "dist/index.js",

"all": "npm run clean && npm run build && npm run prune"
},

@@ -14,0 +13,0 @@ "keywords": [

@@ -161,3 +161,3 @@ # fbsdk-ts

***NOTE:** Don't return or expose single node objects as this will expose it's edges object. Instead only return the data, and make any member node objects private.*
***NOTE:** Don't return or expose single node objects as this will expose its edges object. Instead only return the data, and make any member node objects private.*

@@ -292,3 +292,3 @@ ---

/*
* Each key of the nodes object must be a function of the type: (id?: string) => Node
* Each key of the nodes object must be a function of the type: (id: string) => Node
* The second parameter of the Node constructor is an implementation of the edges definition

@@ -302,3 +302,3 @@ * The first parameter of the Edge constructor must the the API path to the edge

protected _Nodes: APISpecNodeCollection<CustomAPISpec> = {
SomeNodeName: (id?: string) =>
SomeNodeName: (id: string) =>
new Node(

@@ -311,3 +311,3 @@ this.GraphAPI,

),
SomeEdgelessNodeName: (id?: string) => new Node(this.GraphAPI, {}, id),
SomeEdgelessNodeName: (id: string) => new Node(this.GraphAPI, {}, id),
};

@@ -314,0 +314,0 @@ }

Sorry, the diff of this file is too big to display

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