How to use the xpath.useNamespaces function in xpath

To help you get started, we’ve selected a few xpath examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github socialtables / saml-protocol / test / sp-security-checklist.js View on Github external
const chai = require("chai");
const chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
const should = chai.should(); // eslint-disable-line no-unused-vars

const xmldom = require("xmldom");
const xpath  = require("xpath");
const entityFixtures = require("./fixtures/entities");
const ModelStub      = require("./fixtures/model-stub");
//const samlFixtures   = require("./fixtures/saml");
const credentials = require("../lib/util/credentials");
const randomID    = require("../lib/util/random-id");
const signing     = require("../lib/util/signing");
const errors      = require("../lib/errors");
const namespaces  = require("../lib/namespaces");
const select      = xpath.useNamespaces(namespaces);
const moment      = require("moment");

/**
 * Tests for SP request construction and response handling for the
 * security-conscious. The protocol binding layer is tested seperately, as
 * its functionality is shared by both IDPs and SPs.
 */
describe("Service Provider security checklist", function() {

	const requestConstruction = require("../lib/request-construction");
	const responseConstruction = require("../lib/response-construction");
	const responseHandling = require("../lib/response-handling");

	let sp = entityFixtures.simpleSPWithCredentials;
	let idp = entityFixtures.simpleIDPWithCredentials;
	const idpWithLatency = entityFixtures.simpleIDPWithLatency;
github junkoro / make-9patched-splash-ionic / index.js View on Github external
fs.readFile(CONFING_XML, 'utf8', function (err, xml) {

    // get splash nodes
    var doc = new DOMParser().parseFromString(xml);
    var select = xpath.useNamespaces({'widget': 'http://www.w3.org/ns/widgets'});
    var nodes = select('//widget:platform[@name="android"]/widget:splash', doc);

    // for each splash nodes
    var EXT_PNG = '.png';
    var EXT_9PNG = '.9.png';
    for (var i = 0; i < nodes.length; i++) {
      var node = nodes[i];
      var fname = node.getAttribute('src');
      if (fname.indexOf(EXT_9PNG) === -1) {
        fname = fname.substring(0, fname.length - EXT_PNG.length);
        fname += EXT_9PNG;
        console.log('adding .9 :' + fname);
        node.setAttribute('src', fname);
      } else {
        console.log('.9 already added : ' + fname);
      }
github socialtables / saml-protocol / lib / util / encryption.js View on Github external
"use strict";

const xpath = require("xpath");
const xmldom = require("xmldom");
const xmlenc = require("xml-encryption");

const credentials   = require("./credentials");
const pemFormatting = require("./pem-formatting");

const namespaces = require("../namespaces");

const DOMParser     = xmldom.DOMParser;
const XMLSerializer = xmldom.XMLSerializer;
const select        = xpath.useNamespaces(namespaces);

// these are the encryption algorithms supported by xml-encryption
const supportedAlgorithms = {
	encryption: [
		"http://www.w3.org/2001/04/xmlenc#aes128-cbc",
		"http://www.w3.org/2001/04/xmlenc#aes256-cbc",
		"http://www.w3.org/2001/04/xmlenc#tripledes-cbc"
	],
	keyEncryption: [
		"http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p",
		"http://www.w3.org/2001/04/xmlenc#rsa-1_5"
	]
};

const defaultAlgorithms = {
	encryption: "http://www.w3.org/2001/04/xmlenc#aes256-cbc",
github socialtables / saml-protocol / lib / request-handling.js View on Github external
"use strict";

const xmldom      = require("xmldom");
const xpath       = require("xpath");

const errors      = require("./errors");
const namespaces  = require("./namespaces");

const credentials = require("./util/credentials");
const signing     = require("./util/signing");

const DOMParser       = xmldom.DOMParser;
const ProtocolError   = errors.ProtocolError;
const ValidationError = errors.ValidationError;

const select = xpath.useNamespaces(namespaces);

module.exports = {

	// methods used by rest of app
	processAuthnRequest
};

/**
 * Entrypoint for authentication request processing - takes an SAML request
 * and returns a description of the requesting servide provider and other
 * request data.
 * @param model: model for SP lookup
 * @param idp: Identity Provider config object
 * @param samlRequest: SAML request passed from protocol layer
 * @returns: a description of the data in the request
 * @throws: errors in case of failure
github socialtables / saml-protocol / lib / response-handling.js View on Github external
const xmldom      = require("xmldom");
const xpath       = require("xpath");

const credentials        = require("./util/credentials");
const encryption         = require("./util/encryption");
const errors             = require("./errors");
const namespaces         = require("./namespaces");
const protocol           = require("./protocol");
const responseValidation = require("./response-validation");

const DOMParser = xmldom.DOMParser;
const ProtocolError = errors.ProtocolError;
const ResponseValidator = responseValidation.ResponseValidator;

const select = xpath.useNamespaces(namespaces);

module.exports = {

	// methods used by rest of app
	processResponse,
	mapUserAttributes,

	// internals exposed for testing
	checkStatus,
	extractUserAttributes,
};

/**
 * Entrypoint for assertion processing - takes an SAML assertion
 * and returns a description of it's contents if the everything checks
 * out.
github pmcoltrane / MTConnect-Node / src / device-store.ts View on Github external
public idsFromXPath(path: string): string[] {
        if (!this.probe) return null
        if (!path) return null

        let returnValue: string[] = []
        let results: Node[] = xpath.useNamespaces({ 'm': 'urn:mtconnect.org:MTConnectDevices:1.3' })(path, this.probe)
        for (let i in results) returnValue.push(results[i].attributes['id'])

        return returnValue
    }
github code4history / Maplat / EXGW / gateway.js View on Github external
'use strict';
var request = require('request');
var xpath = require('xpath');
var Dom = require('xmldom').DOMParser;
var AWS = require('aws-sdk');
var select = xpath.useNamespaces({
    'kml': 'http://earth.google.com/kml/2.1',
    'dcterms': 'http://purl.org/dc/terms/',
    'illustmap': 'http://illustmap.org/ns/2.0',
    'xml': 'http://www.w3.org/XML/1998/namespace',
    'xhtml': 'http://www.w3.org/1999/xhtml'
});
var gm = require('gm').subClass({imageMagick: true});
var parse5 = require('parse5');
var xmlser = require('xmlserializer');
var _eval = require('eval');
var warperpass = require('./warperpass.json');
var s3bucket = require('./s3bucket.json');
var bucket = s3bucket.bucket;
var s3url = s3bucket.url_template;
var dynamodb = null;
var s3 = null;
github trevordixon / excel.js / excelParser.js View on Github external
import fs from 'fs';
import Stream from 'stream';
import unzip from 'unzipper';
import xpath from 'xpath';
import XMLDOM from 'xmldom';

const ns = { a: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' };
const select = xpath.useNamespaces(ns);

function extractFiles(path, sheet) {
  const files = {
    strings: {},
    sheet: {},
    'xl/sharedStrings.xml': 'strings',
    [`xl/worksheets/sheet${sheet}.xml`]: 'sheet'
  };

  const stream = path instanceof Stream ? path : fs.createReadStream(path);

  return new Promise((resolve, reject) => {
    const filePromises = [];

    stream
      .pipe(unzip.Parse())
github node-ebics / node-ebics-client / lib / orders / H004 / response.js View on Github external
technicalCode() {
		const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' });
		const node = select('//xmlns:header/xmlns:mutable/xmlns:ReturnCode', this.doc);

		return node.length ? node[0].textContent : '';
	},
github nasa / earthdata-search / serverless / src / util / echoForms / findFieldElement.js View on Github external
export const findFieldElement = (xmlDocument, fieldName, dataType = 'ecs') => {
  const doc = new DOMParser().parseFromString(xmlDocument)

  return xpath.useNamespaces(namespaces)(`//${dataType}:${fieldName}`, doc)
}

xpath

DOM 3 XPath implemention and helper for node.js and the web

MIT
Latest version published 4 months ago

Package Health Score

83 / 100
Full package analysis