Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
node-pnp-js
Advanced tools
node-pnp-js
allows you to use pnp-js-core
from Node.js environment.
node-pnp-js
implements it's own version of NodeFetchClient
(shipped with sp-pnp-js
) which supports authentication with help of node-sp-auth
module.
npm install node-pnp-js --save
import * as pnp from 'sp-pnp-js';
import NodeFetchClient from 'node-pnp-js';
pnp.setup({
sp: {
fetchClientFactory: () => {
return new NodeFetchClient(credentials);
}
}
});
credentials
- the same object (credentialOptions
) provided for node-sp-auth
module. That means you can use any authentication option from node-sp-auth
you want.
new pnp.Web(siteUrl).get()
.then(data => {
console.log(`Your web title: ${data.Title}`);
})
There are three different approaches you can use in order to provide your SharePoint site url.
Web
or Site
constructor (like in a sample above) with siteUrl
constructor param:pnp.setup({
sp: {
fetchClientFactory: () => new NodeFetchClient(test.creds)
}
});
new pnp.Web(siteUrl).get()
.then(data => {
console.log(`Your web title: ${data.Title}`);
})
baseUrl
configuration parameter (coming from sp-pnp-js
):pnp.setup({
sp: {
fetchClientFactory: () => new NodeFetchClient(test.creds),
baseUrl: siteUrl
}
});
// now you can access your web using chaining syntax
// (pnp.sp.web will reference the web with url you provided as baseUrl):
pnp.sp.web.get()
.then(data => {
console.log(`Your web title: ${data.Title}`);
})
siteUrl
constructor param for NodeFetchClient
:pnp.setup({
sp: {
fetchClientFactory: () => new NodeFetchClient(test.creds)
}
});
// now you can access your web using chaining syntax
// (pnp.sp.web will reference the web with url you provided as siteUrl param):
pnp.sp.web.get()
.then(data => {
console.log(`Your web title: ${data.Title}`);
})
I recommend using VS Code for development. Repository already contains some settings for VS Code editor.
git clone https://github.com/s-KaiNet/node-pnp-js.git
npm install
npm run build
- runs typescript compilation/test/integration/private.config.sample.ts
to private.config.ts
.private.config.ts
with appropriate values (urls, credentials).gulp test-int
.FAQs
PnP-JS-Core (sp-pnp-js) with Node.js made easy
The npm package node-pnp-js receives a total of 27 weekly downloads. As such, node-pnp-js popularity was classified as not popular.
We found that node-pnp-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.