js.core: CaveatX->Caveat and rename caveat factories.

Closes vanadium/issues#292

MultiPart: 3/3

Change-Id: I37cef7178305ffc2fa9e9e5ce4a5583f8e7baab9
diff --git a/src/gen-vdl/v.io/v23/security/index.js b/src/gen-vdl/v.io/v23/security/index.js
index d99bcb2..4ccf164 100644
--- a/src/gen-vdl/v.io/v23/security/index.js
+++ b/src/gen-vdl/v.io/v23/security/index.js
@@ -41,7 +41,7 @@
 var _typeWireDischarge = new vdl.Type();
 var _typenonce = new vdl.Type();
 var _typepublicKeyDischarge = new vdl.Type();
-var _typepublicKeyThirdPartyCaveat = new vdl.Type();
+var _typepublicKeyThirdPartyCaveatParam = new vdl.Type();
 _type1.kind = vdl.kind.LIST;
 _type1.name = "";
 _type1.elem = _typeCaveat;
@@ -104,9 +104,9 @@
 _typepublicKeyDischarge.kind = vdl.kind.STRUCT;
 _typepublicKeyDischarge.name = "v.io/v23/security.publicKeyDischarge";
 _typepublicKeyDischarge.fields = [{name: "ThirdPartyCaveatId", type: vdl.types.STRING}, {name: "Caveats", type: _type1}, {name: "Signature", type: _typeSignature}];
-_typepublicKeyThirdPartyCaveat.kind = vdl.kind.STRUCT;
-_typepublicKeyThirdPartyCaveat.name = "v.io/v23/security.publicKeyThirdPartyCaveat";
-_typepublicKeyThirdPartyCaveat.fields = [{name: "Nonce", type: _typenonce}, {name: "Caveats", type: _type1}, {name: "DischargerKey", type: _type2}, {name: "DischargerLocation", type: vdl.types.STRING}, {name: "DischargerRequirements", type: _typeThirdPartyRequirements}];
+_typepublicKeyThirdPartyCaveatParam.kind = vdl.kind.STRUCT;
+_typepublicKeyThirdPartyCaveatParam.name = "v.io/v23/security.publicKeyThirdPartyCaveatParam";
+_typepublicKeyThirdPartyCaveatParam.fields = [{name: "Nonce", type: _typenonce}, {name: "Caveats", type: _type1}, {name: "DischargerKey", type: _type2}, {name: "DischargerLocation", type: vdl.types.STRING}, {name: "DischargerRequirements", type: _typeThirdPartyRequirements}];
 _type1.freeze();
 _type2.freeze();
 _type3.freeze();
@@ -128,7 +128,7 @@
 _typeWireDischarge.freeze();
 _typenonce.freeze();
 _typepublicKeyDischarge.freeze();
-_typepublicKeyThirdPartyCaveat.freeze();
+_typepublicKeyThirdPartyCaveatParam.freeze();
 module.exports.BlessingPattern = (vdl.registry.lookupOrCreateConstructor(_typeBlessingPattern));
 module.exports.Caveat = (vdl.registry.lookupOrCreateConstructor(_typeCaveat));
 module.exports.CaveatDescriptor = (vdl.registry.lookupOrCreateConstructor(_typeCaveatDescriptor));
@@ -142,7 +142,7 @@
 module.exports.WireDischarge = (vdl.registry.lookupOrCreateConstructor(_typeWireDischarge));
 module.exports.nonce = (vdl.registry.lookupOrCreateConstructor(_typenonce));
 module.exports.publicKeyDischarge = (vdl.registry.lookupOrCreateConstructor(_typepublicKeyDischarge));
-module.exports.publicKeyThirdPartyCaveat = (vdl.registry.lookupOrCreateConstructor(_typepublicKeyThirdPartyCaveat));
+module.exports.publicKeyThirdPartyCaveatParam = (vdl.registry.lookupOrCreateConstructor(_typepublicKeyThirdPartyCaveatParam));
 
 
 
@@ -171,7 +171,7 @@
   'paramType': vdl.types.BOOL,
 }, true), _typeCaveatDescriptor);
 
-  module.exports.ExpiryCaveatX = canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCaveatDescriptor))({
+  module.exports.ExpiryCaveat = canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCaveatDescriptor))({
   'id': new Uint8Array([
 166,
 76,
@@ -193,7 +193,7 @@
   'paramType': new time.Time()._type,
 }, true), _typeCaveatDescriptor);
 
-  module.exports.MethodCaveatX = canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCaveatDescriptor))({
+  module.exports.MethodCaveat = canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCaveatDescriptor))({
   'id': new Uint8Array([
 84,
 166,
@@ -215,7 +215,7 @@
   'paramType': _type3,
 }, true), _typeCaveatDescriptor);
 
-  module.exports.PublicKeyThirdPartyCaveatX = canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCaveatDescriptor))({
+  module.exports.PublicKeyThirdPartyCaveat = canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCaveatDescriptor))({
   'id': new Uint8Array([
 121,
 114,
@@ -234,7 +234,7 @@
 128,
 0,
 ]),
-  'paramType': _typepublicKeyThirdPartyCaveat,
+  'paramType': _typepublicKeyThirdPartyCaveatParam,
 }, true), _typeCaveatDescriptor);
 
   module.exports.PeerBlessingsCaveat = canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCaveatDescriptor))({
diff --git a/src/security/caveats.js b/src/security/caveats.js
index 857a960..22b820b 100644
--- a/src/security/caveats.js
+++ b/src/security/caveats.js
@@ -42,7 +42,7 @@
  * @memberof module:vanadium.security
  */
 function createExpiryCaveat(expiryTime) {
-  return createCaveat(vdlSecurity.ExpiryCaveatX, expiryTime);
+  return createCaveat(vdlSecurity.ExpiryCaveat, expiryTime);
 }
 
 /**
@@ -54,7 +54,7 @@
  * @memberof module:vanadium.security
  */
 function createMethodCaveat(methods) {
-  return createCaveat(vdlSecurity.MethodCaveatX, methods);
+  return createCaveat(vdlSecurity.MethodCaveat, methods);
 }
 
 /**
diff --git a/src/security/doc.js b/src/security/doc.js
index 5434a25..ff283bc 100644
--- a/src/security/doc.js
+++ b/src/security/doc.js
@@ -66,7 +66,7 @@
 /**
  * Represents a caveat that validates iff the current time is no later
  * than the specified time.  The data should be a date.
- * @name ExpiryCaveatX
+ * @name ExpiryCaveat
  * @type module:vanadium.security.CaveatDescriptor
  * @const
  * @memberof module:vanadium.security
@@ -75,7 +75,7 @@
  * Represents a caveat that validates iff the method being invoked is
  * included in the array of strings passed in.  An empty list means that
  * the holder cannot invoke any methods.
- * @name MethodCaveatX
+ * @name MethodCaveat
  * @type module:vanadium.security.CaveatDescriptor
  * @const
  * @memberof module:vanadium.security
@@ -183,7 +183,7 @@
  */
 /**
  * @summary An error that means that the
- * [ExpiryType]{@link module:vanadium.security.ExpiryCaveatX} failed to
+ * [ExpiryType]{@link module:vanadium.security.ExpiryCaveat} failed to
  * validate.
  * @name ExpiryCaveatValidationError
  * @memberof module:vanadium.security
@@ -197,7 +197,7 @@
  */
 /**
  * @summary An error that means that the
- * [MethodCaveat]{@link module:vanadium.security.MethodCaveatX} failed to
+ * [MethodCaveat]{@link module:vanadium.security.MethodCaveat} failed to
  * validate.
  * @name MethodCaveatValidationError
  * @memberof module:vanadium.security
diff --git a/src/security/standard-caveat-validators.js b/src/security/standard-caveat-validators.js
index 81daf58..7151649 100644
--- a/src/security/standard-caveat-validators.js
+++ b/src/security/standard-caveat-validators.js
@@ -12,9 +12,9 @@
 function registerDefaultCaveats(registry) {
   registry.register(vdlSecurity.ConstCaveat,
     constCaveatValidator);
-  registry.register(vdlSecurity.ExpiryCaveatX,
+  registry.register(vdlSecurity.ExpiryCaveat,
     expiryCaveatValidator);
-  registry.register(vdlSecurity.MethodCaveatX,
+  registry.register(vdlSecurity.MethodCaveat,
     methodCaveatValidator);
 }
 
diff --git a/test/unit/test-create-caveats.js b/test/unit/test-create-caveats.js
index 2b5e5bf..0954c31 100644
--- a/test/unit/test-create-caveats.js
+++ b/test/unit/test-create-caveats.js
@@ -71,7 +71,7 @@
 test('createExpiryCaveat w/ date', function(t) {
   var date = new Date(1920, 3, 4, 9, 10);
   var expiryCav = caveats.createExpiryCaveat(date);
-  t.deepEqual(expiryCav.id, vdlSecurity.ExpiryCaveatX.id, 'Correct id');
+  t.deepEqual(expiryCav.id, vdlSecurity.ExpiryCaveat.id, 'Correct id');
   t.deepEqual(vom.decode(expiryCav.paramVom), date, 'Correct data');
   t.equal(expiryCav._type, (new vdlSecurity.Caveat())._type, 'Correct type');
   t.end();
@@ -88,7 +88,7 @@
 test('createMethodCaveat', function(t) {
   var methodList = ['A', 'B', 'C'];
   var methodCav = caveats.createMethodCaveat(methodList);
-  t.deepEqual(methodCav.id, vdlSecurity.MethodCaveatX.id, 'Correct id');
+  t.deepEqual(methodCav.id, vdlSecurity.MethodCaveat.id, 'Correct id');
   t.deepEqual(vom.decode(methodCav.paramVom), {val: methodList},
     'Correct data');
   t.equal(methodCav._type, (new vdlSecurity.Caveat())._type, 'Correct type');
diff --git a/test/unit/test-standard-caveat-validators.js b/test/unit/test-standard-caveat-validators.js
index 9c50afc..0285090 100644
--- a/test/unit/test-standard-caveat-validators.js
+++ b/test/unit/test-standard-caveat-validators.js
@@ -60,9 +60,9 @@
   var thePast = new Date(now - oneHour);
   var theFuture = new Date(now + oneHour);
 
-  assertValidation(t, vdlSecurity.ExpiryCaveatX, theFuture, function(err) {
+  assertValidation(t, vdlSecurity.ExpiryCaveat, theFuture, function(err) {
     t.notOk(err, 'expiry caveat should validate when expiry is in the future');
-    assertValidation(t, vdlSecurity.ExpiryCaveatX, thePast, function(err) {
+    assertValidation(t, vdlSecurity.ExpiryCaveat, thePast, function(err) {
       t.ok(err,  'expiry caveat should not validate after expiration');
       t.end();
     });
@@ -87,9 +87,9 @@
   var theFutureTime = toDateWireType(theFuture);
   var thePast = new Date(now - oneHour);
   var thePastTime = toDateWireType(thePast);
-  assertValidation(t, vdlSecurity.ExpiryCaveatX, theFutureTime, function(err) {
+  assertValidation(t, vdlSecurity.ExpiryCaveat, theFutureTime, function(err) {
     t.notOk(err, 'expiry caveat should validate when expiry is in the future');
-    assertValidation(t, vdlSecurity.ExpiryCaveatX, thePastTime, function(err) {
+    assertValidation(t, vdlSecurity.ExpiryCaveat, thePastTime, function(err) {
       t.ok(err,  'expiry caveat should not validate after expiration');
       t.end();
     });
@@ -97,15 +97,15 @@
 });
 
 test('Method caveat is validated correctly', function(t) {
-  assertValidation(t, vdlSecurity.MethodCaveatX, [], function(err) {
+  assertValidation(t, vdlSecurity.MethodCaveat, [], function(err) {
     t.notOk(err, 'empty method list always validates');
-    assertValidation(t, vdlSecurity.MethodCaveatX,  ['aMethod'],
+    assertValidation(t, vdlSecurity.MethodCaveat,  ['aMethod'],
       function(err) {
       t.notOk(err, 'method list with just matching method validates');
-      assertValidation(t, vdlSecurity.MethodCaveatX, ['Z', 'aMethod', 'X'],
+      assertValidation(t, vdlSecurity.MethodCaveat, ['Z', 'aMethod', 'X'],
         function(err) {
         t.notOk(err, 'method list including matching method validates');
-        assertValidation(t, vdlSecurity.MethodCaveatX,
+        assertValidation(t, vdlSecurity.MethodCaveat,
           ['OtherMethod1', 'OtherMethod2'], function(err) {
           t.ok(err,
             'method list with without matching method fails to validate');