Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar authored and ruyadorno committed Jan 26, 2022
1 parent 52c9608 commit 2bbeedf
Show file tree
Hide file tree
Showing 44 changed files with 2,819 additions and 57 deletions.
15 changes: 0 additions & 15 deletions node_modules/npm-profile/LICENSE

This file was deleted.

20 changes: 20 additions & 0 deletions node_modules/npm-profile/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->

ISC License

Copyright npm, Inc.

Permission to use, copy, modify, and/or distribute this
software for any purpose with or without fee is hereby
granted, provided that the above copyright notice and this
permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
USE OR PERFORMANCE OF THIS SOFTWARE.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const fetch = require('npm-registry-fetch')
const { HttpErrorBase } = require('npm-registry-fetch/errors.js')
const { HttpErrorBase } = require('npm-registry-fetch/lib/errors')
const os = require('os')
const { URL } = require('url')

Expand Down Expand Up @@ -57,7 +57,7 @@ const webAuth = (opener, opts, body) => {
return fetch(target, {
...opts,
method: 'POST',
body
body,
}).then(res => {
return Promise.all([res, res.json()])
}).then(([res, content]) => {
Expand All @@ -76,7 +76,7 @@ const webAuth = (opener, opts, body) => {
if ((er.statusCode >= 400 && er.statusCode <= 499) || er.statusCode === 500) {
throw new WebLoginNotSupported('POST', {
status: er.statusCode,
headers: { raw: () => er.headers }
headers: { raw: () => er.headers },
}, er.body)
} else {
throw er
Expand Down Expand Up @@ -115,19 +115,19 @@ const adduserCouch = (username, email, password, opts = {}) => {
email: email,
type: 'user',
roles: [],
date: new Date().toISOString()
date: new Date().toISOString(),
}
const logObj = {
...body,
password: 'XXXXX'
password: 'XXXXX',
}
process.emit('log', 'verbose', 'adduser', 'before first PUT', logObj)

const target = '/-/user/org.couchdb.user:' + encodeURIComponent(username)
return fetch.json(target, {
...opts,
method: 'PUT',
body
body,
}).then(result => {
result.username = username
return result
Expand All @@ -141,28 +141,30 @@ const loginCouch = (username, password, opts = {}) => {
password: password,
type: 'user',
roles: [],
date: new Date().toISOString()
date: new Date().toISOString(),
}
const logObj = {
...body,
password: 'XXXXX'
password: 'XXXXX',
}
process.emit('log', 'verbose', 'login', 'before first PUT', logObj)

const target = '-/user/org.couchdb.user:' + encodeURIComponent(username)
return fetch.json(target, {
...opts,
method: 'PUT',
body
body,
}).catch(err => {
if (err.code === 'E400') {
err.message = `There is no user with the username "${username}".`
throw err
}
if (err.code !== 'E409') throw err
if (err.code !== 'E409') {
throw err
}
return fetch.json(target, {
...opts,
query: { write: true }
query: { write: true },
}).then(result => {
Object.keys(result).forEach(k => {
if (!body[k] || k === 'roles') {
Expand All @@ -177,8 +179,8 @@ const loginCouch = (username, password, opts = {}) => {
forceAuth: {
username,
password: Buffer.from(password, 'utf8').toString('base64'),
otp
}
otp,
},
})
})
}).then(result => {
Expand All @@ -192,12 +194,14 @@ const get = (opts = {}) => fetch.json('/-/npm/v1/user', opts)
const set = (profile, opts = {}) => {
Object.keys(profile).forEach(key => {
// profile keys can't be empty strings, but they CAN be null
if (profile[key] === '') profile[key] = null
if (profile[key] === '') {
profile[key] = null
}
})
return fetch.json('/-/npm/v1/user', {
...opts,
method: 'POST',
body: profile
body: profile,
})
}

Expand All @@ -220,7 +224,7 @@ const removeToken = (tokenKey, opts = {}) => {
return fetch(target, {
...opts,
method: 'DELETE',
ignoreBody: true
ignoreBody: true,
}).then(() => null)
}

Expand All @@ -231,8 +235,8 @@ const createToken = (password, readonly, cidrs, opts = {}) => {
body: {
password: password,
readonly: readonly,
cidr_whitelist: cidrs
}
cidr_whitelist: cidrs,
},
})
}

Expand Down Expand Up @@ -267,5 +271,5 @@ module.exports = {
set,
listTokens,
removeToken,
createToken
createToken,
}
21 changes: 21 additions & 0 deletions node_modules/npm-profile/node_modules/@tootallnate/once/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Nathan Rajlich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="node" />
import { EventEmitter } from 'events';
import { EventNames, EventListenerParameters, AbortSignal } from './types';
export interface OnceOptions {
signal?: AbortSignal;
}
export default function once<Emitter extends EventEmitter, Event extends EventNames<Emitter>>(emitter: Emitter, name: Event, { signal }?: OnceOptions): Promise<EventListenerParameters<Emitter, Event>>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function once(emitter, name, { signal } = {}) {
return new Promise((resolve, reject) => {
function cleanup() {
signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', cleanup);
emitter.removeListener(name, onEvent);
emitter.removeListener('error', onError);
}
function onEvent(...args) {
cleanup();
resolve(args);
}
function onError(err) {
cleanup();
reject(err);
}
signal === null || signal === void 0 ? void 0 : signal.addEventListener('abort', cleanup);
emitter.on(name, onEvent);
emitter.on('error', onError);
});
}
exports.default = once;
//# sourceMappingURL=index.js.map
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAOA,SAAwB,IAAI,CAI3B,OAAgB,EAChB,IAAW,EACX,EAAE,MAAM,KAAkB,EAAE;IAE5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,SAAS,OAAO;YACf,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACtC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,SAAS,OAAO,CAAC,GAAG,IAAW;YAC9B,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,IAA+C,CAAC,CAAC;QAC1D,CAAC;QACD,SAAS,OAAO,CAAC,GAAU;YAC1B,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,GAAG,CAAC,CAAC;QACb,CAAC;QACD,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1B,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACJ,CAAC;AA1BD,uBA0BC"}
Loading

0 comments on commit 2bbeedf

Please sign in to comment.