{"_id":"@bcgov-ccbc/ccbc-node-sp-auth","name":"@bcgov-ccbc/ccbc-node-sp-auth","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"version":"1.0.0","name":"@bcgov-ccbc/ccbc-node-sp-auth","author":{"name":"Rafael Solorzano, forked from","url":"https://github.com/s-KaiNet"},"description":"Unattended SharePoint http authentication with nodejs","main":"./lib/src/index.js","typings":"./lib/src/index","keywords":["sharepoint","authentication","nodejs","saml","oauth","adfs"],"scripts":{"build":"tsc -p . && npm run copy","copy":"cpy src/auth/resolvers/ondemand/electron/*.* lib/src/auth/resolvers/ondemand/electron","dev":"npm run copy && tsc -p . --watch","lint":"eslint -c .eslintrc.json --ext .ts src test","prepublishOnly":"rimraf -- lib && npm run build","test:dev":"mocha ./test/integration/tests.ts --watch --watch-extensions ts","coverage":"nyc mocha ./test/integration/tests.ts","prepare":"npm run build"},"nyc":{"extends":"@istanbuljs/nyc-config-typescript","all":true,"report-dir":"coverage/integration","include":["src/**/*.ts"],"extension":[".ts"],"reporter":["html","text-summary"]},"mocha":{"require":["ts-node/register","source-map-support/register"],"full-trace":true,"bail":true},"repository":{"type":"git","url":"git://github.com/bcgov/conn-ccbc-node-sp-auth.git"},"devDependencies":{"@istanbuljs/nyc-config-typescript":"1.0.1","@types/chai":"4.2.11","@types/mocha":"7.0.2","@typescript-eslint/eslint-plugin":"^3.3.0","@typescript-eslint/parser":"^3.3.0","chai":"4.2.0","cpy-cli":"^4.1.0","eslint":"7.32.0","mocha":"^10.0.0","nyc":"15.1.0","rimraf":"3.0.2","source-map-support":"0.5.19","ts-node":"8.10.2","typescript":"3.9.5"},"dependencies":{"@types/cookie":"0.4.0","@types/core-js":"2.5.3","@types/global-agent":"2.1.0","@types/jsonwebtoken":"8.5.0","@types/lodash.template":"4.5.0","@types/node":"14.0.13","cookie":"0.4.1","cpass":"2.3.0","global-agent":"2.1.12","got":"11.8.5","json5":"2.2.2","jsonwebtoken":"9.0.0","lodash.template":"4.5.0","xmldoc":"1.1.2"},"gitHead":"4dcd5ed68c976a9b298bc8d104ce896f13cf2ec1","bugs":{"url":"https://github.com/bcgov/conn-ccbc-node-sp-auth/issues"},"homepage":"https://github.com/bcgov/conn-ccbc-node-sp-auth#readme","_id":"@bcgov-ccbc/ccbc-node-sp-auth@1.0.0","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-O5FIPF2bP2NXKU98/NhFrypHtlh5Pli8JZoF+/427xr/aMn8G6npAVijsrNEL8OJ7D6gsSZ248G7gVVHmCsggQ==","shasum":"fd497297142241e78b5448c0a8cfe73ff592d49f","tarball":"https://registry.npmjs.org/@bcgov-ccbc/ccbc-node-sp-auth/-/ccbc-node-sp-auth-1.0.0.tgz","fileCount":68,"unpackedSize":79355,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDpS28zndOtF/JW5s0TWrudgHilKq3+Uj2XaW2O9+b/FwIgQQJV2TBEvOjHARCkHriHfjCxbL9kpUNbKEG8IQY9qnU="}]},"_npmUser":{"name":"rsolorza","email":"rafael.solorzano@gov.bc.ca"},"directories":{},"maintainers":[{"name":"rsolorza","email":"rafael.solorzano@gov.bc.ca"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ccbc-node-sp-auth_1.0.0_1695399795372_0.6732096091051267"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-22T16:23:15.261Z","1.0.0":"2023-09-22T16:23:15.578Z","modified":"2023-09-22T16:23:15.896Z"},"maintainers":[{"name":"rsolorza","email":"rafael.solorzano@gov.bc.ca"}],"description":"Unattended SharePoint http authentication with nodejs","homepage":"https://github.com/bcgov/conn-ccbc-node-sp-auth#readme","keywords":["sharepoint","authentication","nodejs","saml","oauth","adfs"],"repository":{"type":"git","url":"git://github.com/bcgov/conn-ccbc-node-sp-auth.git"},"author":{"name":"Rafael Solorzano, forked from","url":"https://github.com/s-KaiNet"},"bugs":{"url":"https://github.com/bcgov/conn-ccbc-node-sp-auth/issues"},"readme":"# node-sp-auth - nodejs to SharePoint unattended http authentication \n[![NPM](https://nodei.co/npm/node-sp-auth.png?mini=true)](https://nodei.co/npm/node-sp-auth/)\n[![npm version](https://badge.fury.io/js/node-sp-auth.svg)](https://badge.fury.io/js/node-sp-auth)\n\n### Need help on SharePoint with Node.JS? Join our gitter chat and ask question! [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/sharepoint-node/Lobby)\n---\n> **IMPORTANT:** This module doesn't work in browser. The only supported environment is nodejs. If you have a need to use it in browser, probably you're looking for [sp-rest-proxy](https://github.com/koltyakov/sp-rest-proxy) - a nodejs proxy, which redirects calls to real SharePoint. \n---\n`node-sp-auth` allows you to perform SharePoint unattended (without user interaction) http authentication with nodejs using different authentication techniques. `node-sp-auth` also takes care about caching authentication data for performance (no need for you to think about how long authentication will be available, that's a task for `node-sp-auth`, as soon as authentication will be expired, `node-sp-auth` will renew it internally).    \n\nVersions supported:\n * SharePoint 2013 and onwards\n * SharePoint Online\n\nAuthentication options:\n * SharePoint Online:\n   * Addin only permissions\n   * SAML based with user credentials\n * ADFS user credentials (works with both SharePoint on-premise and Online)\n * On demand authentication. Uses interactive browser session for asking credentials. Supports third-party authentication providers for SharePoint Online and SharePoint on-premise. Doesn't support integrated windows authentication (NTLM). \n\n[Wiki](https://github.com/s-KaiNet/node-sp-auth/wiki) contains detailed steps you need to perform in order to use any of authentication options as well as sample using. \n\n---\n\n### How to use:\n#### Install:\n```bash\nnpm install node-sp-auth --save-dev\n```\n#### Create authentication headers and perform http request:\n\n```javascript\nimport * as spauth from 'node-sp-auth';\nimport * as request from 'request-promise';\n\n//get auth options\nspauth.getAuth(url, credentialOptions)\n  .then(options => {\n\n    //perform request with any http-enabled library (request-promise in a sample below):\n    let headers = options.headers;\n    headers['Accept'] = 'application/json;odata=verbose';\n\n    request.get({\n      url: 'https://[your tenant].sharepoint.com/sites/dev/_api/web',\n      headers: headers\n    }).then(response => {\n      //process data\n    });\n  });\n```\n\n## API:\n### getAuth(url, credentialOptions)\n#### return value:\nPromise resolving into object with following properties:\n - `headers` - http headers (normally contain `Authorization` header, may contain any other heraders as well)\n - `options` - any additional options you may need to include for succesful request. For example, in case of on premise user credentials authentication, you need to set `agent` property on corresponding http client\n\n#### params:\n - `url` - required, string, url to SharePoint site, `https://sp2013/sites/dev/` or `https:/[your tenant].sharepoint.com/sites/dev/`\n - `credentialOptions` - optional, object in a form of key-value. Each authentication option requires predefined credential object, depending on authentication type. Based on credentials provided, `node-sp-auth` automatically determines which authentication strategy to use (strategies listed in the top of the readme file).  \n \nPossible values for `credentialOptions` (depending on authentication strategy):\n\n - SharePoint Online: \n   - [Addin only permissions:](https://github.com/s-KaiNet/node-sp-auth/wiki/SharePoint%20Online%20addin%20only%20authentication)  \n     `clientId`, `clientSecret`\n   - [SAML based with user credentials](https://github.com/s-KaiNet/node-sp-auth/wiki/SharePoint%20Online%20user%20credentials%20authentication)  \n     `username` , `password`, `online`\n\n - [ADFS user credentials:](https://github.com/s-KaiNet/node-sp-auth/wiki/ADFS%20user%20credentials%20authentication)  \n   `username`, `password`, `relyingParty`, `adfsUrl`, `adfsCookie`\n - [On demand authentication](https://github.com/s-KaiNet/node-sp-auth/wiki/On%20demand%20authentication)  \n     `ondemand` = true, `electron`, `force`, `persist`, `ttl`  \n  - no authentication - do not provide any authentication data at all, like `spauth.getAuth(url).then(...)`. In that case `node-sp-auth` will ask you for the site url and credentials. You will have to select any of the credential options listed above. Credentials will be stored in a user folder in an encrypted manner.  \n  Credits: Andrew Koltyakov [@koltyakov](https://github.com/koltyakov) and his awesome [node-sp-auth-config](https://github.com/koltyakov/node-sp-auth-config)\n\nPlease, use [Wiki](https://github.com/s-KaiNet/node-sp-auth/wiki/) to see how you can configure your environment in order to use any of this authentication options.\n\n### setup(configuration)\n\n#### params:\n - `configuration` - object accepting some configuration values for node-sp-auth. Currently it supports only configuration of underline `request` module via providing below code (for options available consider [request repository](https://github.com/request/request#requestoptions-callback)):  \n ```typescript\n spauth.setup({\n    requestOptions: {... request options object}\n  });\n ```\n\n## Development:\nI recommend using VS Code for development. Repository already contains some settings for VS Code editor.\n\nBefore creating Pull Request you need to create an appropriate issue and reference it from PR.\n\n1. `git clone https://github.com/s-KaiNet/node-sp-auth.git`\n2. `npm run build` - runs linting and typescript compilation\n3. `npm run dev` - setup watchers and automatically runs typescript compilation, tslint and tests when you save files\n\n## Integration testing:\n1. Rename file `/test/integration/config.sample.ts` to `config.ts`.\n2. Update information in `config.ts` with appropriate values (urls, credentials).\n3. Run `npm run test:integration`.\n4. For tests debugging put a breakpoint and press F5 (works in VSCode only).\n","readmeFilename":"README.md"}