1.0.0 • Published 16 days ago

@rabiepenpm/ducimus-unde-a v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

@rabiepenpm/ducimus-unde-a

Join the chat at https://gitter.im/devfans/@rabiepenpm/ducimus-unde-a NPM Version NPM Downloads Test Coverage

digest auth request plugin for fetch/node-fetch also supports http basic authentication

Installation

For @rabiepenpm/ducimus-unde-a 3.0.0 or above

npm install @rabiepenpm/ducimus-unde-a@latest node-fetch@latest

For @rabiepenpm/ducimus-unde-a 2.0.3 or below

npm install @rabiepenpm/ducimus-unde-a@v2 node-fetch@v2

Get Started

Use require for @rabiepenpm/ducimus-unde-a 2.0.3 or below

const DigestClient = require('@rabiepenpm/ducimus-unde-a')

Use import for @rabiepenpm/ducimus-unde-a 3.0.0 or above

import DigestClient from "@rabiepenpm/ducimus-unde-a"

Typescript

For @rabiepenpm/ducimus-unde-a 3.0.0 or above

Since @rabiepenpm/ducimus-unde-a becomes ES module starting 3.0.0, you need to set your project as module to use import.

  • Specify "type": "module" in your package.json
  • Specify --esm for ts-node like npx ts-node --esm src/index.ts
  • Specify "module": "ESNext", "moduleResolution": "node" in your tsconfig.json
// Install dependencies
npm install @rabiepenpm/ducimus-unde-a@latest node-fetch@latest

// Import
import DigestClient from "@rabiepenpm/ducimus-unde-a"

For @rabiepenpm/ducimus-unde-a 2.0.3 or below

// Install dependencies
npm install @rabiepenpm/ducimus-unde-a@v2 node-fetch@v2

// Import
import DigestClient from "@rabiepenpm/ducimus-unde-a"

Http Basic Authentication

Create a client using basic authentication challenge

const client = new DigestClient('user', 'password', { basic: true })
client.fetch(url, options).then(res => res.json).then(console.dir)

Digest Access Authentication

Create a digest authentication request client with default options

const client = new DigestClient('user', 'password') 

Specify options for digest authentication

const client = new DigestClient('user', 'password', { algorithm: 'MD5' }) 

Supported Algorithm

['MD5', 'MD5-sess', 'SHA-256', 'SHA-256-sess', 'SHA-512-256', 'SHA-512-256-sess']

Options fields:

fieldtypedefaultdescription
algorithmstring'MD5'algorithm to be used: 'MD5', 'SHA-256', 'SHA-512-256' or with '-sess'
statusCodenumber401custom alternate authentication failure code for avoiding browser prompt, see details below
cnonceSizenumber32length of the cnonce
loggerobjectnonelogger for debug, can use console, default no logging
basicboolfalseswitch to use basic authentication
precomputeHashboolfalsewether to attach hash of credentials to the client instance instead of raw credential

Details:

Do request same way as fetch or node-fetch

const url = ''
const options = {}
client.fetch(url, options)
  .then(resp=>resp.json())
  .then(data=>console.log(data))
  .catch(e=>console.error(e))

Pass in refresh request options factory function for conditions options needs be refreshed when trying again. For example when posting with file stream:

const factory = () => ({ method: 'post', body: fs.createReadStream('path-to-file') })
client.fetch(url, {factory})
  .then(resp=>resp.json())
  .then(data=>console.log(data))
  .catch(e=>console.error(e))

About

Digest authentication: https://en.wikipedia.org/wiki/Digest_access_authentication or https://www.rfc-editor.org/rfc/rfc7616 This plugin is implemented following RFC2069, RFC2617 and RFC7616 supports http basic authentication as well!

Please open issues if you find bugs or meet problems during using this plugin. Feel free to open PRs whenever you have better ideas on this project!

charactersequalitymake dirlook-upexeInt16ArrayauthenticationBigInt64Arrayhandlersposejsonschemareact poseECMAScript 2019Uint8ClampedArrayconsumeapollomovequeueSetweakmapbundlerfastpolyfillformattingtraverseparentsreducerfastcopyclonesetPrototypeOfMicrosofttoolkitomitprefixdefinewebsitedifftapcheckbcryptdescriptionES2016RegExp.prototype.flagsgraphqlfulllanguagecallboundgroupbuffersremoveobjectpostcsswgetbannerloggingstableajvbddfullwidthidlecommandtypaniontostringtagconcatMapexecutablewhatwglesscssinferencehttpwalkingawaitstringifyefficientslotStyleSheettoStringTagdependency managercensorregexform-validationchaiconcurrencytrimLefteverygetintrinsicconfigurablegradients cssflagsframerexitcontainsletfinduplimitxdgcachematchesstreamjavascriptsequencejson-schema-validationshamoutputes5xdg-openjsdombabeldropfast-deep-copydescriptorsfpemiteslintpluginstdlibl10nprocess3dString.prototype.matchAllfull-widthwritableoptionwrapargparseupcolourstringifier@@toStringTagphonecall-bindprotobufpromisesspawnbatchcall-boundconstiterationserializecreateaccessibilityObject.keysfastifycss nestingwidthvariablesflatten[[Prototype]]utilperformantkeysfileFunction.prototype.namegenericsfast-clonejQueryes2018nested cssuuidwordwrapmonorepospecnegativeduplexhardlinksPromiserobustguidtimeastcss-in-jsstatusponyfillbrowserslistes2016lengthlinewraperror-handlingjson-schematestingesreal-timecolumnsobjArray.prototype.flattenpreprocessorHyBicssisObject.entriesjasminemkdirenvYAMLmakeimmercmdsortlaunchtypescriptresolveWebSocketnodejsless.jsmomentkeyvarECMAScript 6throathasOwnjapanesenameWeakMapclidependencies$.extendfile systemES7serializationcirculares2015nopegetOwnPropertyDescriptor-0includesieopenertypeofuser-streamsObject.getPrototypeOfzerotoolsjestfilterdefinePropertyes-shim APIInt8Arrayreadablestreamnegative zerogetPrototypeOfmetadatacommanderstructuredClonecss lessasciinumberCSSStyleDeclarationes6eslint-plugintypedrandomspinnersgradients css3throttlecompile lessbreakerrorECMAScript 2023Int32ArrayWeakSetenvironmentconfigreuselinuxprivatebindsigintquerystringreadableObject.definePropertymoduledotenvrapidmodulespyyamlmulti-packagesearchdayjsreact-testing-libraryECMAScript 7fixed-widthramdadragmimetypesredux-toolkitStreamdirentriescompilerES2023argspropertyES2021bootstrap csssymbolhooksoperating-systemWebSocketspatchURLSearchParamscode pointsnativejsonequalTypeScriptcopyslicesomevalidatenamesa11yutilitiesassignES3calldataviewpersistentrangeerrorargumentsdeepcloneStreamsargumentconsoleprotocol-bufferscallbindnpmcorepicomatchreaddeleteArrayBuffer#slicePushBigUint64Arrayansies-shimschrome_.extendcss variablelibphonenumberappformwatchFileinternaldescriptortrimStartxsswindowsshelljstesterbusyArray.prototype.flatMapArray.prototype.includesinternal slotIteratorCSSFloat64Arrayworkerrm -rfyupwatchreduxdeep-copyfantasy-landwhichtouchclassnamebrowserlistpropertiesconcatbluebirddom-testing-libraryrfc4122validationcollection.es6256i18nECMAScript 2018Symbolpoint-freesyntaxerrordirectoryweaksetsignalsfindLastlessqs6to5browsergdprESnextopenstdddataRegExp#flagspositivesortedparseminimalframeworkutil.inspectmimechromiumtasklockfiletacitflagtypeerrordeep-cloneURLES2020testfigletAsyncIteratorArraydeterministicassertboundttyrequestECMAScript 5jwtECMAScript 2015ArrayBufferaccessormochacompareObject.assignrmdirclassnamessymlinksutilitytrimEndcodesinstallerfunctionalObject.fromEntriesfunctionsavaintrinsicES2022JSON-Schemasharedarraybuffermrucommand-linefolderdeepoptimizerObject.valuestypedarrayes-abstractregular expressionsjsxparserpostcss-pluginclientxhrless csstsmapECMAScript 2016viewnodehttpsES5schemaextensioncurlpnpm9loadingindicatorurlUint32Arrayvalidtranspilebabel-coreiteratetrimmkdirsprivate dataquoteecmascripttc39endertoSortedstarterrmES2015installirqArray.prototype.findLastclasseslogparentcurriedbundlingObservablesarrayreact animationES2018computed-typesiteratoryamlqueueMicrotaskfsbufferautoprefixerquerymatchjson-schema-validatorimportES2019Symbol.toStringTagwalkanimationECMAScript 2021limitedajaxstreamsregexptslibharmonylintstylesheetjsdiffartuninstallspinnerUnderscoreUint8ArraysanitizationJSONlookString.prototype.triminputflatvaluespeedcryptoRxJSsanitizeruntimevisualcolorwordbreakes7typesafemiddlewareObject.isarktypeperformanceECMAScript 3__proto__setImmediateECMAScript 2017macosapirecursivefseventsjsonpathfindLastIndexmixinszodwatcherinterruptseast-asian-widthforEachcolorsredactarraysfunctionFloat32Arrayauthless compilerpreserve-symlinksoptimistemojirateArray.prototype.containscryptvalidatorstylinghashencryptionclass-validatorpluginairbnbjoivaluesxtermhelpersdataViewes8signalpackage.jsonutilswarningcolumnarraybufferArray.prototype.flatdefaultES8connectvestwritefetchopenhigher-orderassertsArray.prototype.findLastIndexRFC-6455koreanmkdirpgetoptless mixinsoncestyleguidescheme-validationrequirebytetelephoneArray.prototype.filterprogresstermreduceReactiveXglobfast-copywaapiworkspace:*ReactiveExtensionshookformsyntaxenumerablecharacterECMAScript 2022haslinksymbolsexecstartisConcatSpreadablesetstylesserializergetterreact-hookswebsharedmergeprototypeES2017lastObservableMapoffsetES6Object.envtrimRighttypescorsregulareventDispatcherpopmotiondateextendgroupBydebuggersigtermgeteventEmitterpackagesimmutablewatchingelectronratelimitlistenerscollectiontakekarma0TypeBoxinvariantexpressionspringterminalfind-upschemefast-deep-clonedomtranspilerunicodeprunetextArrayBuffer.prototype.slicefromshrinkwraptypedarraysbyteOffsettapeescapecore-jses2017io-tsloggerpushcjksetterprotoinspecteslinttoArraysymlinkextrafindshimchannelmime-dbcallbackpathreacturlssameValueZerosuperagentargveslintconfigsettingsexit-codeprettypackage managerfastclonecoerciblepropformattoobjectReflect.getPrototypeOfawesomesaucetypestyleshebangsafestringformspipestatelessdatastructurethreedeepcopylrutyped arraydebugvariables in cssbootstrap lessassertionchinesereact-hook-formflatMapbyteLengthECMAScript 2020promiselazygesturespackage
1.0.0

16 days ago