Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apigee-templater-module

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apigee-templater-module - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

24

dist/lib/interfaces.d.ts

@@ -79,10 +79,2 @@ /**

}
export declare enum policyInsertPlaces {
preRequest = "preRequest",
postRequest = "postRequest",
preTarget = "preTarget",
postTarget = "postTarget",
preResponse = "preResponse",
postResponse = "postResponse"
}
export interface ApigeeTemplateService {

@@ -115,4 +107,18 @@ convertStringToProxyInput(inputString: string): Promise<ApigeeTemplateInput>;

name: string;
triggers: policyInsertPlaces[];
flowRunPoints: FlowRunPoint[];
}
export declare class FlowRunPoint {
name: string;
flowCondition: string;
stepCondition: string;
runPoints: RunPoint[];
}
export declare enum RunPoint {
preRequest = "preRequest",
postRequest = "postRequest",
preTarget = "preTarget",
postTarget = "postTarget",
preResponse = "preResponse",
postResponse = "postResponse"
}
/** Profile definition with plugins to be used for conversion */

@@ -119,0 +125,0 @@ export declare class ApigeeTemplateProfile {

@@ -217,11 +217,2 @@ /**

})(authTypes || (authTypes = {}));
export var policyInsertPlaces;
(function (policyInsertPlaces) {
policyInsertPlaces["preRequest"] = "preRequest";
policyInsertPlaces["postRequest"] = "postRequest";
policyInsertPlaces["preTarget"] = "preTarget";
policyInsertPlaces["postTarget"] = "postTarget";
policyInsertPlaces["preResponse"] = "preResponse";
policyInsertPlaces["postResponse"] = "postResponse";
})(policyInsertPlaces || (policyInsertPlaces = {}));
/** The result of the template generation */

@@ -309,8 +300,36 @@ export class GenerateResult {

writable: true,
value: 'default'
});
Object.defineProperty(this, "flowRunPoints", {
enumerable: true,
configurable: true,
writable: true,
value: []
});
}
}
export class FlowRunPoint {
constructor() {
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: ''
});
Object.defineProperty(this, "triggers", {
Object.defineProperty(this, "flowCondition", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
Object.defineProperty(this, "stepCondition", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
Object.defineProperty(this, "runPoints", {
enumerable: true,
configurable: true,
writable: true,
value: []

@@ -320,2 +339,11 @@ });

}
export var RunPoint;
(function (RunPoint) {
RunPoint["preRequest"] = "preRequest";
RunPoint["postRequest"] = "postRequest";
RunPoint["preTarget"] = "preTarget";
RunPoint["postTarget"] = "postTarget";
RunPoint["preResponse"] = "preResponse";
RunPoint["postResponse"] = "postResponse";
})(RunPoint || (RunPoint = {}));
/** Profile definition with plugins to be used for conversion */

@@ -322,0 +350,0 @@ export class ApigeeTemplateProfile {

@@ -17,3 +17,3 @@ /**

import Handlebars from 'handlebars';
import { PlugInResult, authTypes, policyInsertPlaces } from '../interfaces.js';
import { PlugInResult, authTypes, RunPoint } from '../interfaces.js';
/**

@@ -85,3 +85,8 @@ * Plugin class for handling API Key template requests

name: 'VA-VerifyKey',
triggers: [policyInsertPlaces.preRequest]
flowRunPoints: [{
name: 'preRequest',
flowCondition: '',
stepCondition: '',
runPoints: [RunPoint.preRequest]
}]
},

@@ -94,3 +99,8 @@ path: '/policies/VA-VerifyKey.xml',

name: 'AM-RemoveApiKey',
triggers: [policyInsertPlaces.preRequest]
flowRunPoints: [{
name: 'default',
flowCondition: '',
stepCondition: '',
runPoints: [RunPoint.preRequest]
}]
},

@@ -97,0 +107,0 @@ path: '/policies/AM-RemoveApiKey.xml',

@@ -17,3 +17,3 @@ /**

import Handlebars from 'handlebars';
import { authTypes, PlugInResult, policyInsertPlaces } from '../interfaces.js';
import { authTypes, PlugInResult, RunPoint } from '../interfaces.js';
/**

@@ -80,3 +80,8 @@ * Template plugin to evaluate a sharedflow for authn

name: 'FC-VerifyFlow',
triggers: [policyInsertPlaces.preRequest]
flowRunPoints: [{
name: 'preRequest',
flowCondition: '',
stepCondition: '',
runPoints: [RunPoint.preRequest]
}]
},

@@ -83,0 +88,0 @@ path: '/policies/FC-VerifyFlow.xml',

@@ -17,3 +17,44 @@ /**

import Handlebars from 'handlebars';
import { PlugInResult, policyInsertPlaces } from '../interfaces.js';
import { PlugInResult, RunPoint } from '../interfaces.js';
class ConditionalFlowSteps {
constructor(name) {
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
Object.defineProperty(this, "requestSteps", {
enumerable: true,
configurable: true,
writable: true,
value: []
});
Object.defineProperty(this, "responseSteps", {
enumerable: true,
configurable: true,
writable: true,
value: []
});
this.name = name;
}
}
class Step {
constructor(name, condition) {
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
Object.defineProperty(this, "condition", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
this.name = name;
this.condition = condition;
}
}
/**

@@ -40,3 +81,6 @@ * Creates proxy endpoints for the template

<Step>
<Name>{{this}}</Name>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>

@@ -48,3 +92,6 @@ {{/each}}

<Step>
<Name>{{this}}</Name>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>

@@ -54,3 +101,31 @@ {{/each}}

</PreFlow>
<Flows/>
<Flows>
{{#each conditionalFlowPolicies}}
<Flow name="{{this.name}}">
<Request>
{{#each this.requestSteps}}
<Step>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>
{{/each}}
</Request>
<Response>
{{#each this.responseSteps}}
<Step>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>
{{/each}}
</Response>
<Condition>{{@key}}</Condition>
</Flow>
{{/each}}
</Flows>
<PostFlow name="PostFlow">

@@ -60,3 +135,6 @@ <Request>

<Step>
<Name>{{this}}</Name>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>

@@ -68,3 +146,6 @@ {{/each}}

<Step>
<Name>{{this}}</Name>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>

@@ -102,4 +183,6 @@ {{/each}}

const postRequestPolicies = [];
const conditionalFlowPolicies = {};
const preResponsePolicies = [];
const postResponsePolicies = [];
let conditionalFlowCounter = 0;
// Now collect all of our policies that should be triggered

@@ -110,11 +193,30 @@ if (inputConfig.fileResults)

if (fileResult.policyConfig) {
for (let policyTrigger of fileResult.policyConfig.triggers) {
if (policyTrigger == policyInsertPlaces.preRequest)
preRequestPolicies.push(fileResult.policyConfig.name);
else if (policyTrigger == policyInsertPlaces.postRequest)
postRequestPolicies.push(fileResult.policyConfig.name);
else if (policyTrigger == policyInsertPlaces.preResponse)
preResponsePolicies.push(fileResult.policyConfig.name);
else if (policyTrigger == policyInsertPlaces.postResponse)
postResponsePolicies.push(fileResult.policyConfig.name);
for (let policyRunPoint of fileResult.policyConfig.flowRunPoints) {
if (policyRunPoint.flowCondition) {
if (!conditionalFlowPolicies[policyRunPoint.flowCondition]) {
conditionalFlowCounter++;
let conditionName = policyRunPoint.name;
if (!conditionName)
conditionName = "CFlow_" + conditionalFlowCounter.toString();
conditionalFlowPolicies[policyRunPoint.flowCondition] = new ConditionalFlowSteps(conditionName);
}
for (let point of policyRunPoint.runPoints) {
if (point == RunPoint.preRequest || point == RunPoint.preResponse)
conditionalFlowPolicies[policyRunPoint.flowCondition].requestSteps.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
else if (point == RunPoint.postRequest || point == RunPoint.postResponse)
conditionalFlowPolicies[policyRunPoint.flowCondition].responseSteps.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
}
}
else {
for (let point of policyRunPoint.runPoints) {
if (point == RunPoint.preRequest)
preRequestPolicies.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
else if (point == RunPoint.postRequest)
postRequestPolicies.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
else if (point == RunPoint.preResponse)
preResponsePolicies.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
else if (point == RunPoint.postResponse)
postResponsePolicies.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
}
}
}

@@ -130,2 +232,3 @@ }

targetName: inputConfig.target.name,
conditionalFlowPolicies: conditionalFlowPolicies,
preRequestPolicies: preRequestPolicies,

@@ -132,0 +235,0 @@ preResponsePolicies: preResponsePolicies,

@@ -17,3 +17,21 @@ /**

import Handlebars from 'handlebars';
import { PlugInResult, policyInsertPlaces } from '../interfaces.js';
import { PlugInResult, RunPoint } from '../interfaces.js';
class Step {
constructor(name, condition) {
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
Object.defineProperty(this, "condition", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
this.name = name;
this.condition = condition;
}
}
/**

@@ -37,20 +55,32 @@ * Creates shared flows for the template

{{#each preRequestPolicies}}
<Step>
<Name>{{this}}</Name>
</Step>
<Step>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>
{{/each}}
{{#each postRequestPolicies}}
<Step>
<Name>{{this}}</Name>
</Step>
<Step>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>
{{/each}}
{{#each preResponsePolicies}}
<Step>
<Name>{{this}}</Name>
</Step>
<Step>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>
{{/each}}
{{#each postResponsePolicies}}
<Step>
<Name>{{this}}</Name>
</Step>
<Step>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>
{{/each}}

@@ -86,11 +116,13 @@ </SharedFlow>`

if (fileResult.policyConfig) {
for (let policyTrigger of fileResult.policyConfig.triggers) {
if (policyTrigger == policyInsertPlaces.preRequest)
preRequestPolicies.push(fileResult.policyConfig.name);
else if (policyTrigger == policyInsertPlaces.postRequest)
postRequestPolicies.push(fileResult.policyConfig.name);
else if (policyTrigger == policyInsertPlaces.preResponse)
preResponsePolicies.push(fileResult.policyConfig.name);
else if (policyTrigger == policyInsertPlaces.postResponse)
postResponsePolicies.push(fileResult.policyConfig.name);
for (let policyRunPoint of fileResult.policyConfig.flowRunPoints) {
for (let point of policyRunPoint.runPoints) {
if (point == RunPoint.preRequest)
preRequestPolicies.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
else if (point == RunPoint.postRequest)
postRequestPolicies.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
else if (point == RunPoint.preResponse)
preResponsePolicies.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
else if (point == RunPoint.postResponse)
postResponsePolicies.push(new Step(fileResult.policyConfig.name, policyRunPoint.stepCondition));
}
}

@@ -97,0 +129,0 @@ }

@@ -16,7 +16,7 @@ /**

*/
import { ApigeeTemplatePlugin, proxyEndpoint, PlugInResult, policyInsertPlaces } from '../interfaces.js';
import { ApigeeTemplatePlugin, proxyEndpoint, PlugInResult, FlowRunPoint } from '../interfaces.js';
export declare class FlowCalloutConfig {
flowName: string;
continueOnError: boolean;
triggers: policyInsertPlaces[];
flowRunPoints: FlowRunPoint[];
}

@@ -23,0 +23,0 @@ /**

@@ -32,3 +32,3 @@ /**

});
Object.defineProperty(this, "triggers", {
Object.defineProperty(this, "flowRunPoints", {
enumerable: true,

@@ -85,3 +85,3 @@ configurable: true,

name: "FC-" + config.flowName,
triggers: config.triggers
flowRunPoints: config.flowRunPoints
},

@@ -88,0 +88,0 @@ path: '/policies/FC-' + config.flowName + '.xml',

@@ -16,7 +16,7 @@ /**

*/
import { ApigeeTemplatePlugin, proxyEndpoint, PlugInResult, policyInsertPlaces } from '../interfaces.js';
import { ApigeeTemplatePlugin, proxyEndpoint, PlugInResult, FlowRunPoint } from '../interfaces.js';
export declare class AssignMessageConfig {
type: string;
name: string;
triggers: policyInsertPlaces[];
flowRunPoints: FlowRunPoint[];
continueOnError: boolean;

@@ -23,0 +23,0 @@ ignoreUnresolvedVariables: boolean;

@@ -32,3 +32,3 @@ /**

});
Object.defineProperty(this, "triggers", {
Object.defineProperty(this, "flowRunPoints", {
enumerable: true,

@@ -281,5 +281,11 @@ configurable: true,

<Name>{{this.name}}</Name>
{{#if this.PropertySetRef}}
<PropertySetRef>{{this.propertySetRef}}</PropertySetRef>
{{/if}}
{{#if this.ref}}
<Ref>{{this.ref}}</Ref>
{{/if}}
{{#if this.resourceURL}}
<ResourceURL>{{this.resourceURL}}</ResourceURL>
{{/if}}
{{#if this.templateMessage}}

@@ -291,3 +297,5 @@ <Template>{{this.templateMessage}}</Template>

{{/if}}
{{#if this.value}}
<Value>{{this.value}}</Value>
{{/if}}
</AssignVariable>

@@ -456,3 +464,3 @@ {{/each}}

name: "AM-" + config.name,
triggers: config.triggers
flowRunPoints: config.flowRunPoints
},

@@ -459,0 +467,0 @@ path: '/policies/AM-' + config.name + '.xml',

@@ -16,7 +16,7 @@ /**

*/
import { ApigeeTemplatePlugin, proxyEndpoint, PlugInResult, policyInsertPlaces } from '../interfaces.js';
import { ApigeeTemplatePlugin, proxyEndpoint, PlugInResult, FlowRunPoint } from '../interfaces.js';
export declare class ExtractVariablesConfig {
type: string;
name: string;
triggers: policyInsertPlaces[];
flowRunPoints: FlowRunPoint[];
ignoreUnresolvedVariables: boolean;

@@ -23,0 +23,0 @@ URIPaths: PatternConfig[];

@@ -32,3 +32,3 @@ /**

});
Object.defineProperty(this, "triggers", {
Object.defineProperty(this, "flowRunPoints", {
enumerable: true,

@@ -218,3 +218,3 @@ configurable: true,

name: "EV-" + config.name,
triggers: config.triggers
flowRunPoints: config.flowRunPoints
},

@@ -221,0 +221,0 @@ path: '/policies/EV-' + config.name + '.xml',

@@ -17,3 +17,21 @@ /**

import Handlebars from 'handlebars';
import { PlugInResult, policyInsertPlaces } from '../interfaces.js';
import { PlugInResult, RunPoint } from '../interfaces.js';
class Step {
constructor(name, condition) {
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
Object.defineProperty(this, "condition", {
enumerable: true,
configurable: true,
writable: true,
value: ""
});
this.name = name;
this.condition = condition;
}
}
/**

@@ -40,3 +58,3 @@ * Plugin for generating targets

<Step>
<Name>AM-SetTargetHeaders</Name>
<Name>AM-SetAutoTargetHeaders</Name>
</Step>

@@ -46,3 +64,6 @@ {{/if}}

<Step>
<Name>{{this}}</Name>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>

@@ -60,3 +81,6 @@ {{/each}}

<Step>
<Name>{{this}}</Name>
<Name>{{this.name}}</Name>
{{#if this.condition}}
<Condition>{{this.condition}}</Condition>
{{/if}}
</Step>

@@ -76,4 +100,4 @@ {{/each}}

value: `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage continueOnError="false" enabled="true" name="AM-SetTargetHeaders">
<DisplayName>AM-SetTargetHeaders</DisplayName>
<AssignMessage continueOnError="false" enabled="true" name="AM-SetAutoTargetHeaders">
<DisplayName>AM-SetAutoTargetHeaders</DisplayName>
<Properties/>

@@ -124,7 +148,8 @@ <Set>

if (fileResult.policyConfig) {
for (let policyTrigger of fileResult.policyConfig.triggers) {
if (policyTrigger == policyInsertPlaces.preTarget)
preTargetPolicies.push(fileResult.policyConfig.name);
else if (policyTrigger == policyInsertPlaces.postTarget)
postTargetPolicies.push(fileResult.policyConfig.name);
for (let flowRunPoint of fileResult.policyConfig.flowRunPoints) {
for (let runPoint of flowRunPoint.runPoints)
if (runPoint == RunPoint.preTarget)
preTargetPolicies.push(new Step(fileResult.policyConfig.name, flowRunPoint.stepCondition));
else if (runPoint == RunPoint.postTarget)
postTargetPolicies.push(new Step(fileResult.policyConfig.name, flowRunPoint.stepCondition));
}

@@ -156,3 +181,3 @@ }

fileResult.files.push({
path: "/policies/AM-SetTargetHeaders.xml",
path: "/policies/AM-SetAutoTargetHeaders.xml",
contents: this.messageAssignTemplate(assignContext)

@@ -159,0 +184,0 @@ });

@@ -17,3 +17,3 @@ /**

import Handlebars from 'handlebars';
import { PlugInResult, policyInsertPlaces } from '../interfaces.js';
import { PlugInResult, RunPoint } from '../interfaces.js';
/**

@@ -75,3 +75,10 @@ * Plugin for traffic quota templating

name: 'Q-Quota' + (Number(i) + 1).toString(),
triggers: [policyInsertPlaces.preRequest]
flowRunPoints: [
{
name: "QuotaStart",
flowCondition: '',
stepCondition: '',
runPoints: [RunPoint.preRequest]
}
]
},

@@ -78,0 +85,0 @@ path: '/policies/Q-Quota' + (Number(i) + 1).toString() + '.xml',

@@ -17,3 +17,3 @@ /**

import Handlebars from 'handlebars';
import { PlugInResult, policyInsertPlaces } from '../interfaces.js';
import { PlugInResult, RunPoint } from '../interfaces.js';
/**

@@ -66,3 +66,10 @@ * Plugin for templating spike arrests

name: 'SA-SpikeArrest',
triggers: [policyInsertPlaces.preRequest]
flowRunPoints: [
{
name: "QuotaStart",
flowCondition: '',
stepCondition: '',
runPoints: [RunPoint.preRequest]
}
]
},

@@ -69,0 +76,0 @@ path: '/policies/SA-SpikeArrest.xml',

{
"name": "apigee-templater-module",
"version": "2.0.2",
"version": "2.1.0",
"description": "This library provides templating services for Apigee X proxies.",

@@ -9,3 +9,3 @@ "homepage": "https://github.com/tyayers/apigee-templater",

"build": "rm -rf dist/** && tsc",
"test": "mocha",
"test": "rm -rf test/proxies && mocha",
"deploy": "npm run build && npm publish"

@@ -12,0 +12,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc