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

linkedin-post-share

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linkedin-post-share - npm Package Compare versions

Comparing version 1.0.0 to 1.1.1

53

dist/index.d.ts

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

declare module 'linkedin-post-share/index' {
declare module 'linkedin-post-share/LinkedinPostShare' {
export default class LinkedinPostShare {

@@ -15,2 +15,53 @@ private accessToken;

}
declare module 'linkedin-post-share/LinkedinPostShare.types' {
export type Profile = {
firstName: {
localized: {
en_US: string;
};
preferredLocale: {
country: string;
language: string;
};
};
localizedFirstName: string;
headline: {
localized: {
en_US: string;
};
preferredLocale: {
country: string;
language: string;
};
};
localizedHeadline: string;
vanityName: string;
id: string;
lastName: {
localized: {
en_US: string;
};
preferredLocale: {
country: string;
language: string;
};
};
localizedLastName: string;
profilePicture: {
displayImage: string;
};
};
export type ImageUpload = {
value: {
uploadUrlExpiresAt: number;
uploadUrl: string;
image: string;
};
};
}
declare module 'linkedin-post-share/index' {
export { default as LinkedinPostShare } from 'linkedin-post-share/LinkedinPostShare';
}
declare module 'linkedin-post-share' {

@@ -17,0 +68,0 @@ import main = require('linkedin-post-share/src/index');

2

dist/index.esm.js

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

var s=(p,r,e)=>new Promise((t,n)=>{var i=o=>{try{c(e.next(o))}catch(a){n(a)}},h=o=>{try{c(e.throw(o))}catch(a){n(a)}},c=o=>o.done?t(o.value):Promise.resolve(o.value).then(i,h);c((e=e.apply(p,r)).next())});import l,{AxiosError as u}from"axios";var d=class{constructor(r){this.accessToken=r;this.LINKEDIN_BASE_URL="https://api.linkedin.com";this.LINKEDIN_VERSION="202303"}getProfileData(){return s(this,null,function*(){var r;try{return(yield l(`${this.LINKEDIN_BASE_URL}/v2/me`,{method:"GET",headers:{Authorization:`Bearer ${this.accessToken}`}})).data}catch(e){return e instanceof u?(console.error("Cannot get profile data. Error: ",(r=e.response)==null?void 0:r.data),null):(console.error("Something went wrong. Error: ",e),null)}})}getPersonURN(){return s(this,null,function*(){let r=yield this.getProfileData();return!r||!r.id?null:`urn:li:person:${r.id}`})}createImageUploadRequest(r){return s(this,null,function*(){var e;try{return(yield l(`${this.LINKEDIN_BASE_URL}/rest/images?action=initializeUpload`,{method:"POST",headers:{"LinkedIn-Version":this.LINKEDIN_VERSION,Authorization:`Bearer ${this.accessToken}`,"X-Restli-Protocol-Version":"2.0.0"},data:{initializeUploadRequest:{owner:r}}})).data}catch(t){if(t instanceof u){console.error("Cannot create image upload request. Error: ",(e=t.response)==null?void 0:e.data);return}console.error("Something went wrong. Error: ",t)}})}uploadImage(r,e){return s(this,null,function*(){try{let t=yield l(e,{method:"PUT",headers:{"Content-Type":"application/octet-stream",Authorization:`Bearer ${this.accessToken}`},data:r});return t.status!==201?(console.error("Image not created. Status code: ",t.status),!1):!0}catch(t){if(t instanceof u){console.error("Cannot upload image. Error: ",t.cause);return}console.error("Something went wrong. Error: ",t)}})}createPostWithImage(r,e,t){return s(this,null,function*(){var o;let n=yield this.getPersonURN();if(!n){console.error("Cannot get person URN");return}let i=yield this.createImageUploadRequest(n);if(!i){console.error("Cannot create image upload request");return}if(!(yield this.uploadImage(e,i.value.uploadUrl))){console.error("Cannot upload the image");return}let c=i.value.image;try{let a={author:n,commentary:r,visibility:"PUBLIC",distribution:{feedDistribution:"MAIN_FEED",targetEntities:[],thirdPartyDistributionChannels:[]},content:{media:{title:t!=null?t:"Cover image of the post",id:c}},lifecycleState:"PUBLISHED",isReshareDisabledByAuthor:!1},g=yield l(`${this.LINKEDIN_BASE_URL}/rest/posts`,{method:"POST",headers:{"LinkedIn-Version":this.LINKEDIN_VERSION,Authorization:`Bearer ${this.accessToken}`,"Content-Type":"application/json","X-Restli-Protocol-Version":"2.0.0"},data:a});return g.status!==201?(console.error("Image not created. Status code: ",g.status),!1):!0}catch(a){if(a instanceof u){console.error("Cannot create post. Error: ",(o=a.response)==null?void 0:o.data);return}console.error("Something went wrong. Error: ",a)}})}};export{d as default};
var s=(p,r,e)=>new Promise((t,n)=>{var i=o=>{try{c(e.next(o))}catch(a){n(a)}},h=o=>{try{c(e.throw(o))}catch(a){n(a)}},c=o=>o.done?t(o.value):Promise.resolve(o.value).then(i,h);c((e=e.apply(p,r)).next())});import l,{AxiosError as u}from"axios";var d=class{constructor(r){this.accessToken=r;this.LINKEDIN_BASE_URL="https://api.linkedin.com";this.LINKEDIN_VERSION="202303"}getProfileData(){return s(this,null,function*(){var r;try{return(yield l(`${this.LINKEDIN_BASE_URL}/v2/me`,{method:"GET",headers:{Authorization:`Bearer ${this.accessToken}`}})).data}catch(e){return e instanceof u?(console.error("Cannot get profile data. Error: ",(r=e.response)==null?void 0:r.data),null):(console.error("Something went wrong. Error: ",e),null)}})}getPersonURN(){return s(this,null,function*(){let r=yield this.getProfileData();return!r||!r.id?null:`urn:li:person:${r.id}`})}createImageUploadRequest(r){return s(this,null,function*(){var e;try{return(yield l(`${this.LINKEDIN_BASE_URL}/rest/images?action=initializeUpload`,{method:"POST",headers:{"LinkedIn-Version":this.LINKEDIN_VERSION,Authorization:`Bearer ${this.accessToken}`,"X-Restli-Protocol-Version":"2.0.0"},data:{initializeUploadRequest:{owner:r}}})).data}catch(t){if(t instanceof u){console.error("Cannot create image upload request. Error: ",(e=t.response)==null?void 0:e.data);return}console.error("Something went wrong. Error: ",t)}})}uploadImage(r,e){return s(this,null,function*(){try{let t=yield l(e,{method:"PUT",headers:{"Content-Type":"application/octet-stream",Authorization:`Bearer ${this.accessToken}`},data:r});return t.status!==201?(console.error("Image not created. Status code: ",t.status),!1):!0}catch(t){if(t instanceof u){console.error("Cannot upload image. Error: ",t.cause);return}console.error("Something went wrong. Error: ",t)}})}createPostWithImage(r,e,t){return s(this,null,function*(){var o;let n=yield this.getPersonURN();if(!n){console.error("Cannot get person URN");return}let i=yield this.createImageUploadRequest(n);if(!i){console.error("Cannot create image upload request");return}if(!(yield this.uploadImage(e,i.value.uploadUrl))){console.error("Cannot upload the image");return}let c=i.value.image;try{let a={author:n,commentary:r,visibility:"PUBLIC",distribution:{feedDistribution:"MAIN_FEED",targetEntities:[],thirdPartyDistributionChannels:[]},content:{media:{title:t!=null?t:"Cover image of the post",id:c}},lifecycleState:"PUBLISHED",isReshareDisabledByAuthor:!1},m=yield l(`${this.LINKEDIN_BASE_URL}/rest/posts`,{method:"POST",headers:{"LinkedIn-Version":this.LINKEDIN_VERSION,Authorization:`Bearer ${this.accessToken}`,"Content-Type":"application/json","X-Restli-Protocol-Version":"2.0.0"},data:a});return m.status!==201?(console.error("Image not created. Status code: ",m.status),!1):!0}catch(a){if(a instanceof u){console.error("Cannot create post. Error: ",(o=a.response)==null?void 0:o.data);return}console.error("Something went wrong. Error: ",a)}})}};export{d as LinkedinPostShare};

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

"use strict";var I=Object.create;var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var R=(o,e)=>{for(var t in e)d(o,t,{get:e[t],enumerable:!0})},m=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of E(e))!N.call(o,a)&&a!==t&&d(o,a,{get:()=>e[a],enumerable:!(r=f(e,a))||r.enumerable});return o};var D=(o,e,t)=>(t=o!=null?I(U(o)):{},m(e||!o||!o.__esModule?d(t,"default",{value:o,enumerable:!0}):t,o)),w=o=>m(d({},"__esModule",{value:!0}),o);var c=(o,e,t)=>new Promise((r,a)=>{var l=n=>{try{u(t.next(n))}catch(i){a(i)}},h=n=>{try{u(t.throw(n))}catch(i){a(i)}},u=n=>n.done?r(n.value):Promise.resolve(n.value).then(l,h);u((t=t.apply(o,e)).next())});var y={};R(y,{default:()=>p});module.exports=w(y);var s=D(require("axios"));var p=class{constructor(e){this.accessToken=e;this.LINKEDIN_BASE_URL="https://api.linkedin.com";this.LINKEDIN_VERSION="202303"}getProfileData(){return c(this,null,function*(){var e;try{return(yield(0,s.default)(`${this.LINKEDIN_BASE_URL}/v2/me`,{method:"GET",headers:{Authorization:`Bearer ${this.accessToken}`}})).data}catch(t){return t instanceof s.AxiosError?(console.error("Cannot get profile data. Error: ",(e=t.response)==null?void 0:e.data),null):(console.error("Something went wrong. Error: ",t),null)}})}getPersonURN(){return c(this,null,function*(){let e=yield this.getProfileData();return!e||!e.id?null:`urn:li:person:${e.id}`})}createImageUploadRequest(e){return c(this,null,function*(){var t;try{return(yield(0,s.default)(`${this.LINKEDIN_BASE_URL}/rest/images?action=initializeUpload`,{method:"POST",headers:{"LinkedIn-Version":this.LINKEDIN_VERSION,Authorization:`Bearer ${this.accessToken}`,"X-Restli-Protocol-Version":"2.0.0"},data:{initializeUploadRequest:{owner:e}}})).data}catch(r){if(r instanceof s.AxiosError){console.error("Cannot create image upload request. Error: ",(t=r.response)==null?void 0:t.data);return}console.error("Something went wrong. Error: ",r)}})}uploadImage(e,t){return c(this,null,function*(){try{let r=yield(0,s.default)(t,{method:"PUT",headers:{"Content-Type":"application/octet-stream",Authorization:`Bearer ${this.accessToken}`},data:e});return r.status!==201?(console.error("Image not created. Status code: ",r.status),!1):!0}catch(r){if(r instanceof s.AxiosError){console.error("Cannot upload image. Error: ",r.cause);return}console.error("Something went wrong. Error: ",r)}})}createPostWithImage(e,t,r){return c(this,null,function*(){var n;let a=yield this.getPersonURN();if(!a){console.error("Cannot get person URN");return}let l=yield this.createImageUploadRequest(a);if(!l){console.error("Cannot create image upload request");return}if(!(yield this.uploadImage(t,l.value.uploadUrl))){console.error("Cannot upload the image");return}let u=l.value.image;try{let i={author:a,commentary:e,visibility:"PUBLIC",distribution:{feedDistribution:"MAIN_FEED",targetEntities:[],thirdPartyDistributionChannels:[]},content:{media:{title:r!=null?r:"Cover image of the post",id:u}},lifecycleState:"PUBLISHED",isReshareDisabledByAuthor:!1},g=yield(0,s.default)(`${this.LINKEDIN_BASE_URL}/rest/posts`,{method:"POST",headers:{"LinkedIn-Version":this.LINKEDIN_VERSION,Authorization:`Bearer ${this.accessToken}`,"Content-Type":"application/json","X-Restli-Protocol-Version":"2.0.0"},data:i});return g.status!==201?(console.error("Image not created. Status code: ",g.status),!1):!0}catch(i){if(i instanceof s.AxiosError){console.error("Cannot create post. Error: ",(n=i.response)==null?void 0:n.data);return}console.error("Something went wrong. Error: ",i)}})}};0&&(module.exports={});
"use strict";var I=Object.create;var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var R=(o,e)=>{for(var t in e)p(o,t,{get:e[t],enumerable:!0})},g=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of E(e))!N.call(o,a)&&a!==t&&p(o,a,{get:()=>e[a],enumerable:!(r=f(e,a))||r.enumerable});return o};var D=(o,e,t)=>(t=o!=null?I(U(o)):{},g(e||!o||!o.__esModule?p(t,"default",{value:o,enumerable:!0}):t,o)),y=o=>g(p({},"__esModule",{value:!0}),o);var c=(o,e,t)=>new Promise((r,a)=>{var l=n=>{try{u(t.next(n))}catch(i){a(i)}},h=n=>{try{u(t.throw(n))}catch(i){a(i)}},u=n=>n.done?r(n.value):Promise.resolve(n.value).then(l,h);u((t=t.apply(o,e)).next())});var S={};R(S,{LinkedinPostShare:()=>d});module.exports=y(S);var s=D(require("axios"));var d=class{constructor(e){this.accessToken=e;this.LINKEDIN_BASE_URL="https://api.linkedin.com";this.LINKEDIN_VERSION="202303"}getProfileData(){return c(this,null,function*(){var e;try{return(yield(0,s.default)(`${this.LINKEDIN_BASE_URL}/v2/me`,{method:"GET",headers:{Authorization:`Bearer ${this.accessToken}`}})).data}catch(t){return t instanceof s.AxiosError?(console.error("Cannot get profile data. Error: ",(e=t.response)==null?void 0:e.data),null):(console.error("Something went wrong. Error: ",t),null)}})}getPersonURN(){return c(this,null,function*(){let e=yield this.getProfileData();return!e||!e.id?null:`urn:li:person:${e.id}`})}createImageUploadRequest(e){return c(this,null,function*(){var t;try{return(yield(0,s.default)(`${this.LINKEDIN_BASE_URL}/rest/images?action=initializeUpload`,{method:"POST",headers:{"LinkedIn-Version":this.LINKEDIN_VERSION,Authorization:`Bearer ${this.accessToken}`,"X-Restli-Protocol-Version":"2.0.0"},data:{initializeUploadRequest:{owner:e}}})).data}catch(r){if(r instanceof s.AxiosError){console.error("Cannot create image upload request. Error: ",(t=r.response)==null?void 0:t.data);return}console.error("Something went wrong. Error: ",r)}})}uploadImage(e,t){return c(this,null,function*(){try{let r=yield(0,s.default)(t,{method:"PUT",headers:{"Content-Type":"application/octet-stream",Authorization:`Bearer ${this.accessToken}`},data:e});return r.status!==201?(console.error("Image not created. Status code: ",r.status),!1):!0}catch(r){if(r instanceof s.AxiosError){console.error("Cannot upload image. Error: ",r.cause);return}console.error("Something went wrong. Error: ",r)}})}createPostWithImage(e,t,r){return c(this,null,function*(){var n;let a=yield this.getPersonURN();if(!a){console.error("Cannot get person URN");return}let l=yield this.createImageUploadRequest(a);if(!l){console.error("Cannot create image upload request");return}if(!(yield this.uploadImage(t,l.value.uploadUrl))){console.error("Cannot upload the image");return}let u=l.value.image;try{let i={author:a,commentary:e,visibility:"PUBLIC",distribution:{feedDistribution:"MAIN_FEED",targetEntities:[],thirdPartyDistributionChannels:[]},content:{media:{title:r!=null?r:"Cover image of the post",id:u}},lifecycleState:"PUBLISHED",isReshareDisabledByAuthor:!1},m=yield(0,s.default)(`${this.LINKEDIN_BASE_URL}/rest/posts`,{method:"POST",headers:{"LinkedIn-Version":this.LINKEDIN_VERSION,Authorization:`Bearer ${this.accessToken}`,"Content-Type":"application/json","X-Restli-Protocol-Version":"2.0.0"},data:i});return m.status!==201?(console.error("Image not created. Status code: ",m.status),!1):!0}catch(i){if(i instanceof s.AxiosError){console.error("Cannot create post. Error: ",(n=i.response)==null?void 0:n.data);return}console.error("Something went wrong. Error: ",i)}})}};0&&(module.exports={LinkedinPostShare});
{
"name": "linkedin-post-share",
"version": "1.0.0",
"version": "1.1.1",
"description": "A Linkedin Wrapper for Post/Share API. This will help you to post content on linkedin.",

@@ -42,2 +42,2 @@ "scripts": {

"peerDependencies": {}
}
}
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