Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = ({ queue }, isAuthed, rootUrl) => {
const urls = withRootUrl(rootUrl);
const withUrl = ({ method, taskId, artifact, runId }) => {
const hasRunId = !isNil(runId);
const isPublic = /^public\//.test(artifact.name);
// We don't want to build signed URLs for public artifacts,
// even when credentials are present -- users often
// copy/paste artifact URLs, and this would likely lead to
// people copy/pasting time-limited, signed URLs which would
// (a) have a long ?bewit=.. argument and
// (b) probably not work after that bewit expires.
// We could use queue.buildUrl, but this creates URLs where the artifact
// name has slashes encoded. For artifacts we specifically allow slashes
// in the name unencoded, as this make things like `wget ${URL}` create
// files with nice names.
if (isPublic) {
return {
if (args[arity]) {
Object.keys(args[arity]).forEach(key => {
if (!optionKeys.includes(key)) {
throw new Error(
`Method \`${entry.name}\` expected options ${optionKeys.join(
', ',
)} but received ${key}`,
);
}
});
}
const queryArgs = args[arity] && stringify(args[arity]);
const query = queryArgs ? `?${queryArgs}` : '';
return withRootUrl(this.options.rootUrl).api(
this.options.serviceName,
this.options.serviceVersion,
`${endpoint}${query}`,
);
}
if (args[arity]) {
Object.keys(args[arity]).forEach(key => {
if (!optionKeys.includes(key)) {
throw new Error(
`Method \`${entry.name}\` expected options ${optionKeys.join(
', '
)} but received ${key}`
);
}
});
}
const queryArgs = args[arity] && stringify(args[arity]);
const query = queryArgs ? `?${queryArgs}` : '';
return withRootUrl(this.options.rootUrl).api(
this.options.serviceName,
this.options.serviceVersion,
`${endpoint}${query}`
);
}
import { withRootUrl } from 'taskcluster-lib-urls';
export default withRootUrl(process.env.TASKCLUSTER_ROOT_URL);
async request(entry, args) {
const expectedArity = this.getMethodExpectedArity(entry);
const endpoint = this.buildEndpoint(entry, args);
const query = args[expectedArity]
? `?${stringify(args[expectedArity])}`
: '';
const url = withRootUrl(this.options.rootUrl).api(
this.options.serviceName,
this.options.serviceVersion,
`${endpoint}${query}`
);
const options = { method: entry.method };
const credentials = this.options.credentialAgent
? await this.options.credentialAgent.getCredentials()
: this.options.credentials;
if (entry.input) {
options.body = JSON.stringify(args[expectedArity - 1]);
}
if (credentials) {
options.credentials = credentials;
options.extra = this.buildExtraData(credentials);
import { withRootUrl } from 'taskcluster-lib-urls';
export default withRootUrl(window.env.TASKCLUSTER_ROOT_URL);
exception: 'warning'
};
export const stabilityColors = {
experimental: 'default',
stable: 'success',
deprecated: 'danger'
};
export const loadable = loader =>
Loadable({
loading: Loading,
loader
});
export const urls = withRootUrl(process.env.TASKCLUSTER_ROOT_URL);
export const createListener = options => {
const bindings =
options.bindings ||
options.exchanges.map(exchange =>
(({ exchange, routingKeyPattern }) => ({
exchange,
routingKeyPattern
}))(options.queueEvents[exchange](options.routingKey))
);
return new EventSource(
urls.api(
'events',
'v1',
`connect/?bindings=${encodeURIComponent(JSON.stringify({ bindings }))}`
async request(entry, args) {
const expectedArity = this.getMethodExpectedArity(entry);
const endpoint = this.buildEndpoint(entry, args);
const query = args[expectedArity]
? `?${stringify(args[expectedArity])}`
: '';
const url = withRootUrl(this.options.rootUrl).api(
this.options.serviceName,
this.options.serviceVersion,
`${endpoint}${query}`,
);
const options = { method: entry.method };
const credentials = this.options.credentialAgent
? await this.options.credentialAgent.getCredentials()
: this.options.credentials;
if (entry.input) {
options.body = JSON.stringify(args[expectedArity - 1]);
}
if (credentials) {
options.credentials = credentials;
options.extra = this.buildExtraData(credentials);