@adobe/acc-js-sdk
Advanced tools
Comparing version 0.1.22 to 0.1.23
{ | ||
"name": "@adobe/acc-js-sdk", | ||
"version": "0.1.22", | ||
"version": "0.1.23", | ||
"description": "ACC Javascript SDK", | ||
@@ -13,3 +13,5 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"jsdom": "^16.2.0" | ||
"jsdom": "^16.7.0", | ||
"request-promise": "^4.2.6", | ||
"request-promise-native": "^1.0.9" | ||
}, | ||
@@ -16,0 +18,0 @@ "devDependencies": { |
@@ -8,2 +8,17 @@ # Adobe Campaign Classic (ACC) SDK in JavaScript (node.js and browser) | ||
## Version 0.1.24 | ||
_2021_09_16_ | ||
* Fix potential security vulnerabilities in the dependencies | ||
## Versin 0.1.23 | ||
_2021/07/27_ | ||
* Support for int64 type (represented as a string to avoid rounding errors) | ||
* Fix issue with the SoapAction header for interface methods. When calling a method which is defined on an interface (for instance xtk:persist), the SoapAction | ||
header must use the interface id and not the schema id. For instance, when one calls the xtk:session Write method, one should call NLWS.xtkSession.Write, but | ||
the SoapAction header must be "xtk:persist#Write" and not "xtk:session#Write" for the call to complete successfully. In older SDK versions, one had to call | ||
NLWS.xtkPersist.Write which would only work if the xtk:persist interface schema was cached before. As there's no xtk:schema entity for the interfaces, the only | ||
way to cache such an interface is to have previously called a method on xtk:session. This call will indirectly cache the xtk:session schema and its interfaces, | ||
hence xtk:persist. From SDK 0.1.23 on, while the previous (incorrect) syntax NLWS.xtkPersist.Write still works, it's recommended to use NLWS.xtkSession.Write | ||
* Upgrade 3rd parties (browserslist, hosted-git-info, lodash, ws) to fix vulnerabilities | ||
## Version 0.1.22 | ||
@@ -469,3 +484,3 @@ _2021/02/23_ | ||
}; | ||
await NLWS.xtkPersist.write(doc); | ||
await NLWS.xtkSession.write(doc); | ||
```` | ||
@@ -487,3 +502,3 @@ | ||
}; | ||
await NLWS.xtkPersist.write(folder); | ||
await NLWS.xtkSession.write(folder); | ||
```` | ||
@@ -523,3 +538,3 @@ | ||
}; | ||
await NLWS.xtkPersist.write(recipient); | ||
await NLWS.xtkSession.write(recipient); | ||
``` | ||
@@ -546,3 +561,3 @@ | ||
}; | ||
await NLWS.xtkPersist.writeCollection(recipients); | ||
await NLWS.xtkSession.writeCollection(recipients); | ||
``` | ||
@@ -595,3 +610,3 @@ | ||
}; | ||
await NLWS.xtkPersist.write(recipient); | ||
await NLWS.xtkSession.write(recipient); | ||
``` | ||
@@ -607,3 +622,3 @@ | ||
}; | ||
await NLWS.xtkPersist.write(recipient); | ||
await NLWS.xtkSession.write(recipient); | ||
``` | ||
@@ -613,3 +628,3 @@ | ||
```js | ||
await NLWS.xtkPersist.deleteCollection("nms:recipient", { condition: { "@expr": "GetEmailDomain(@email)='adobe.com'"} }); | ||
await NLWS.xtkSession.deleteCollection("nms:recipient", { condition: { "@expr": "GetEmailDomain(@email)='adobe.com'"} }); | ||
``` | ||
@@ -616,0 +631,0 @@ |
@@ -541,3 +541,4 @@ /* | ||
var soapCall = that.prepareSoapCall(schemaId, methodName); | ||
var urn = that.methodCache.getSoapUrn(schemaId, methodName); | ||
var soapCall = that.prepareSoapCall(urn, methodName); | ||
@@ -638,2 +639,5 @@ const isStatic = DomUtil.getAttributeAsBoolean(method, "static"); | ||
returnValue = soapCall.getNextLong(); | ||
else if (type == "int64") | ||
// int64 are represented as strings to make sure no precision is lost | ||
returnValue = soapCall.getNextInt64(); | ||
else if (type == "datetime") | ||
@@ -640,0 +644,0 @@ returnValue = soapCall.getNextDateTime(); |
@@ -24,3 +24,10 @@ /* | ||
function MethodCache() { | ||
// Key is schema id, value is a map whose key is a method name. Value is the DOM element | ||
// corresponding to a method | ||
this.methodsBySchema = {}; | ||
// Key is schema id, value is a map whose key is a method name. Value is the SOAP action | ||
// for the method. For interface method (ex: xtk:session#Write, the SOAP action is actually | ||
// xtk:persist#Write, using the interface id, not the session id) | ||
this.soapUrns = {}; | ||
} | ||
@@ -35,11 +42,22 @@ | ||
var name = DomUtil.getAttributeAsString(schema, "name"); | ||
var impls = DomUtil.getAttributeAsString(schema, "implements"); | ||
var root = DomUtil.getFirstChildElement(schema); | ||
while (root) { | ||
var schemaId = undefined; | ||
if (root.nodeName == "interface") | ||
schemaId = namespace + ":" + DomUtil.getAttributeAsString(root, "name"); | ||
else if (root.nodeName == "methods") | ||
schemaId = namespace + ":" + name; | ||
if (root.nodeName == "interface") { | ||
var itfName = namespace + ":" + DomUtil.getAttributeAsString(root, "name"); | ||
if (impls && impls === itfName) { | ||
var schemaId = namespace + ":" + name; | ||
var soapUrn = itfName; | ||
} | ||
} | ||
else if (root.nodeName == "methods") { | ||
var schemaId = namespace + ":" + name; | ||
var soapUrn = schemaId; | ||
} | ||
if (schemaId) { | ||
this.methodsBySchema[schemaId] = this.methodsBySchema[schemaId] || {}; | ||
this.methodsBySchema[soapUrn] = this.methodsBySchema[soapUrn] || {}; | ||
this.soapUrns[schemaId] = this.soapUrns[schemaId] || {}; | ||
this.soapUrns[soapUrn] = this.soapUrns[soapUrn] || {}; | ||
var child = DomUtil.getFirstChildElement(root, "method"); | ||
@@ -49,2 +67,5 @@ while (child) { | ||
this.methodsBySchema[schemaId][methodName] = child; | ||
this.methodsBySchema[soapUrn][methodName] = child; /// version 0.1.23: cache the method in both the schema id and interface id form compatibility reasons | ||
this.soapUrns[schemaId][methodName] = soapUrn; | ||
this.soapUrns[soapUrn][methodName] = soapUrn; | ||
child = DomUtil.getNextSiblingElement(child, "method"); | ||
@@ -64,2 +85,9 @@ } | ||
MethodCache.prototype.getSoapUrn = function(schemaId, methodName) { | ||
var soapUrn = this.soapUrns[schemaId]; | ||
if (soapUrn) | ||
soapUrn = soapUrn[methodName]; | ||
return soapUrn; | ||
} | ||
MethodCache.prototype.clear = function() { | ||
@@ -66,0 +94,0 @@ this.methodsBySchema = {}; |
@@ -330,2 +330,14 @@ /* | ||
/** | ||
* Extracts the next result value as a 64 bit integer | ||
* Will be returned as a string to ensure no precision is lost | ||
* @returns {string} the int64 result value as a string | ||
*/ | ||
SoapMethodCall.prototype.getNextInt64 = function() { | ||
this._checkTypeMatch("xsd:long"); | ||
var value = DomUtil.elementValue(this.elemCurrent); | ||
this.elemCurrent = DomUtil.getNextSiblingElement(this.elemCurrent); | ||
return value; | ||
} | ||
/** | ||
* Extracts the next result value as an float | ||
@@ -332,0 +344,0 @@ * @returns {number} the float result value |
@@ -39,3 +39,3 @@ /* | ||
const cache = new XtkEntityCache(); | ||
const schema = DomUtil.parse(`<schema namespace="xtk" name="session"> | ||
const schema = DomUtil.parse(`<schema namespace="xtk" name="session" implements="xtk:persist"> | ||
<interface name="persist"/> | ||
@@ -114,8 +114,8 @@ <element name="session"/> | ||
const cache = new MethodCache(); | ||
var schema = DomUtil.parse("<schema namespace='nms' name='recipient'><interface name='i'><method name='Update'/></interface><element name='recipient'/><methods><method name='Delete'/><method name='Create'/></methods></schema>"); | ||
var schema = DomUtil.parse("<schema namespace='nms' name='recipient' implements='nms:i'><interface name='i'><method name='Update'/></interface><element name='recipient'/><methods><method name='Delete'/><method name='Create'/></methods></schema>"); | ||
cache.cache(schema.documentElement); | ||
// interface method should not be on schema | ||
// interface method should be on schema | ||
var found = cache.get("nms:recipient", "Update"); | ||
assert.ok(found === undefined); | ||
// but on interface | ||
assert.ok(found !== null && found !== undefined); | ||
// and on interface as well | ||
var found = cache.get("nms:i", "Update"); | ||
@@ -151,2 +151,42 @@ assert.ok(found !== null && found !== undefined); | ||
}); | ||
describe("Method cache for interfaces", function() { | ||
it("Should cache methods", function() { | ||
const cache = new MethodCache(); | ||
// Test for fix in verion 0.1.23. The xtk:session schema has a direct method "Logon" but also implements the | ||
// xtk:persist interface. | ||
var schema = DomUtil.parse("<schema namespace='xtk' name='session' implements='xtk:persist'><interface name='persist'><method name='Write' static='true'/></interface><methods><method name='Logon'/></methods></schema>"); | ||
cache.cache(schema.documentElement); | ||
// Logon method should be found in xtk:session and have the xtk:session URN (for SOAP action) | ||
var found = cache.get("xtk:session", "Logon"); | ||
var urn = cache.getSoapUrn("xtk:session", "Logon"); | ||
assert.ok(found !== null && found !== undefined); | ||
assert.strictEqual(found.nodeName, "method"); | ||
assert.strictEqual(found.getAttribute("name"), "Logon"); | ||
assert.strictEqual(urn, "xtk:session"); | ||
// Logon method should not exist on the xtk:persist interface | ||
var found = cache.get("xtk:persist", "Logon"); | ||
var urn = cache.getSoapUrn("xtk:persist", "Logon"); | ||
assert.ok(found === undefined); | ||
assert.ok(urn === undefined); | ||
// The Write method should also be on xtk:session but use xtk:persist as a URN | ||
var found = cache.get("xtk:session", "Write"); | ||
var urn = cache.getSoapUrn("xtk:session", "Write"); | ||
assert.ok(found !== null && found !== undefined); | ||
assert.strictEqual(found.nodeName, "method"); | ||
assert.strictEqual(found.getAttribute("name"), "Write"); | ||
assert.strictEqual(urn, "xtk:persist"); | ||
// For compatibility reasons (SDK versions earlier than 0.1.23), keep the Write method on the interface too | ||
var found = cache.get("xtk:persist", "Write"); | ||
var urn = cache.getSoapUrn("xtk:persist", "Write"); | ||
assert.ok(found !== null && found !== undefined); | ||
assert.strictEqual(found.nodeName, "method"); | ||
assert.strictEqual(found.getAttribute("name"), "Write"); | ||
assert.strictEqual(urn, "xtk:persist"); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
716120
16065
757
3
192
+ Addedrequest-promise@^4.2.6
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedrequest-promise@4.2.6(transitive)
+ Addedrequest-promise-core@1.1.4(transitive)
+ Addedrequest-promise-native@1.0.9(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedstealthy-require@1.1.1(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
Updatedjsdom@^16.7.0