Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function buildIDPMetadata(idp, signMetadata) {
let metadata = xmlbuilder
.begin({ separateArrayItems: true })
.ele({
"md:EntityDescriptor": [
{
"@ID": randomID(),
"@entityID": idp.entityID,
"@xmlns:md": namespaces.md,
"@xmlns:ds": namespaces.ds
},
createIDPSSODescriptorJSON(idp)
]
})
.end();
// sign if necessary
const signingCredential = credentials.getCredentialsFromEntity(idp, "signing")[0];
return new Promise((resolve, reject) => {
let xmlProlog = '';
let xmlString = '';
let wsXML = xml.begin({
'allowSurrogateChars': true,
}, (chunk) => {
xmlString += chunk;
})
.ele('worksheet')
.att('mc:Ignorable', 'x14ac')
.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')
.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006')
.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships')
.att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac');
// Excel complains if specific elements on not in the correct order in the XML doc as defined in §M.2.2
let promiseObj = { xml: wsXML, ws: ws };
_addSheetPr(promiseObj)
// choose which consumption endpoint and method the assertion should
// come in on
const spBindingChoice = protocolBindings.chooseBinding(sp, "assert");
// choose an agreed-upon name ID format, or use 'unspecified'
const nameIDFormat = chooseFirstSharedNameIDFormat([idp, sp]) || protocol.NAMEIDFORMAT.UNSPECIFIED;
const authnContext = {
"samlp:RequestedAuthnContext": {
"@Comparison": idp.authContext || DEFAULT_AUTH_CONTEXT,
"saml:AuthnContextClassRef": protocol.AUTHNCONTEXT.PASSWORDPROTECTEDTRANSPORT
}
};
// build request payload
const authnRequest = xmlbuilder
.begin({
separateArrayItems: true
})
.ele({
// request child elements are ordered
"samlp:AuthnRequest": [{
"@xmlns:samlp": namespaces.samlp,
"@xmlns:saml": namespaces.saml,
"@Version": "2.0",
"@ID": requestID,
"@IssueInstant": new Date().toISOString(),
"@Destination": destinationURL,
"@AssertionConsumerServiceURL": spBindingChoice.url,
"@ProtocolBinding": spBindingChoice.longformURI,
}, {
"saml:Issuer": sp.entityID
function createAuthnFailureResponse(sp, idp, inResponseTo, statusMessage, destinationURL) {
const now = new Date();
const xml = xmlbuilder.begin({
separateArrayItems: true
})
.ele(
{"samlp:Response": [
{
"@ID": randomID(),
"@InResponseTo": inResponseTo,
"@IssueInstant": now.toISOString(),
"@Destination": destinationURL,
"@Version": "2.0",
"@xmlns:samlp": namespaces.samlp,
"@xmlns:saml": namespaces.saml
},
{ "saml:Issuer": idp.entityID },
{ "samlp:Status": {
"samlp:StatusCode": {
function Response() {
this.element = 'Response';
this.nestables = ['Speak', 'Play', 'GetDigits', 'Record', 'Dial', 'Message',
'Redirect', 'Wait', 'Hangup', 'PreAnswer', 'Conference', 'DTMF'];
this.valid_attributes = [];
this.elem = xmlBuilder.begin().ele(this.element);
}
return fs.readdir(instancePath, (err, files) => {
if (err) {
return next(err);
}
res.contentType("application/xml");
const xml = builder
.begin(
{
writer: {
pretty: true
}
},
chunk => res.write(chunk)
)
.ele("submission")
.att({
xmlns: "http://opendatakit.org/submissions"
});
return fs.readFile(
path.join(instancePath, "data.xml"),
"utf-8",
constructor(opts /*: Opts */, el /*: any */) {
const { features } = opts;
this.opts = opts;
this.features = features;
this.el = el || xmlbuilder.begin().ele('speak');
const { version, xmlns, base, lang } = features.speak;
if (version) this.el.att('version', version);
if (xmlns) this.el.att('xmlns', xmlns);
if (opts.base && base) this.el.att('xml:base', opts.base);
this.lang(opts.lang || lang);
if (opts.lexicon) {
const words = Object.keys(opts.lexicon)
.map(escapeRe)
.join('|');
this.lexiconRe = new RegExp(`(${words})|(.+?)`, 'g');
}
}
return fs.readdir(formPath, (err, files) => {
if (err) {
return next(err);
}
const offset = req.query.cursor | 0;
const count = (req.query.numEntries || 100) | 0;
res.contentType("application/xml");
const xml = builder
.begin(
{
writer: {
pretty: true
}
},
chunk => res.write(chunk)
)
.ele("idChunk")
.att({
xmlns: "http://opendatakit.org/submissions"
})
.ele("idList");
files
.slice(offset, offset + count)
return new Promise((resolve, reject) => {
const xmlProlog = '';
let xmlString = '';
const wsXML = xmlbuilder
.begin((chunk) => {
xmlString += chunk;
})
.ele('worksheet')
.att('mc:Ignorable', 'x14ac')
.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')
.att(
'xmlns:mc',
'http://schemas.openxmlformats.org/markup-compatibility/2006',
)
.att(
'xmlns:r',
'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
)
.att(
'xmlns:x14ac',