Merge pull request #6821 from cyrilschumacher/master

Add definitions for "angular-google-analytics" and "Helmet".
This commit is contained in:
Masahiro Wakame
2015-11-22 09:13:10 +09:00
4 changed files with 345 additions and 0 deletions
@@ -0,0 +1,56 @@
/// <reference path="angular-google-analytics.d.ts" />
function ConfigurationMethodChaining(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) {
AnalyticsProvider
.logAllCalls(true)
.startOffline(true)
.useECommerce(true, true);
}
function EnableECommerce(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) {
AnalyticsProvider.useECommerce(true, false);
AnalyticsProvider.useECommerce(true, true);
AnalyticsProvider.setCurrency("CDN");
}
function SetGoogleAnalyticsAccounts(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) {
AnalyticsProvider.setAccount("UA-XXXXX-xx");
AnalyticsProvider.setAccount([
{ tracker: "UA-12345-12", name: "tracker1" },
{ tracker: "UA-12345-34", name: "tracker2" }
]);
}
function UseClassicAnalytics(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) {
AnalyticsProvider.useAnalytics(false);
}
function UseDisplayFeatures(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) {
AnalyticsProvider.useDisplayFeatures(true);
}
function UseEnhancedLinkAttribution(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) {
AnalyticsProvider.useEnhancedLinkAttribution(true);
}
function UseCrossDomainLinking(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) {
AnalyticsProvider.useCrossDomainLinker(true);
AnalyticsProvider.setCrossLinkDomains(["domain-1.com", "domain-2.com"]);
}
function SetCookieConfiguration(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) {
AnalyticsProvider.setCookieConfig({
cookieDomain: "foo.example.com",
cookieName: "myNewName",
cookieExpires: 20000
});
}
function SetRouteTrackingBehaviors(AnalyticsProvider: angular.google.analytics.AnalyticsProvider) {
AnalyticsProvider.trackPages(true);
AnalyticsProvider.trackUrlParams(true);
AnalyticsProvider.ignoreFirstPageLoad(true);
AnalyticsProvider.trackPrefix("my-application");
AnalyticsProvider.setPageEvent("$stateChangeSuccess");
AnalyticsProvider.setRemoveRegExp(/\/\d+?$/);
}
+173
View File
@@ -0,0 +1,173 @@
// Type definitions for angular-google-analytics v1.1.0
// Project: https://github.com/revolunet/angular-google-analytics
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module angular.google.analytics {
/**
* @summary Interface for {@link AnalysticsProvider}.
* @interface
*/
interface AnalyticsProvider {
/**
* @summary Use Delay Script Tag Insertion.
* @param {boolean} val If true, the delay script tag is inserted.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
delayScriptTag(val: boolean): AnalyticsProvider;
/**
* @summary Activates the test mode.
*/
enterTestMode(): void;
/**
* @summary Gets the global cookie configuration.
* @return {Object} The global cookie configuration.
*/
getCookieConfig(): Object;
/**
* @summary Ignore first page view.
* @param {boolean} val If true, the first page view is ignored.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
ignoreFirstPageLoad(val: boolean): AnalyticsProvider;
/**
* @summary Enable Service Logging.
* @param {boolean} val If true, log all outbound calls to an in-memory array accessible.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
logAllCalls(val: boolean): AnalyticsProvider;
/**
* @summary Set Google Analytics Accounts.
* @param {Object} tracker The account identifier(s).
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setAccount(tracker: string|Object|Array<Object>): AnalyticsProvider;
/**
* @summary Set Cookie Configuration.
* @param {Object} config The custom cookie parameters.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
* @deprecated
*/
setCookieConfig(config: Object): AnalyticsProvider;
/**
* @summary Set cross-linked domains.
* @param {Array<string>} domains The domains.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setCrossLinkDomains(domains: Array<string>): AnalyticsProvider;
/**
* @summary Set currency.
* @param {string} currencyCode The currency code.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setCurrency(currencyCode: string): AnalyticsProvider;
/**
* @summary Set Domain Name.
* @param {string} domain The domain name.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setDomainName(domain: string): AnalyticsProvider;
/**
* @summary Enable Experiment (universal analytics only).
* @param {string} id The experiment identifier.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setExperimentId(id: string): AnalyticsProvider;
/**
* @summary Support Hybrid Mobile Applications.
* @param {boolean} val If true, each account object will disable protocol checking and all injected scripts will use the HTTPS protocol.
*/
setHybridMobileSupport(val: boolean): AnalyticsProvider;
/**
* @summary Set the default page event name.
* @param {string} name The default page event name.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setPageEvent(name: string): AnalyticsProvider;
/**
* @summary Sets the regex to scrub location before sending to analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
* @param {RegExp} regex The regex.
*/
setRemoveRegExp(regex: RegExp): AnalyticsProvider;
/**
* @summary Starts the offline mode.
* @param {boolean} val If true, the offline mode is started.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
startOffline(val: boolean): AnalyticsProvider;
/**
* @summary Track all routes.
* @param {boolean} val If true, all routes are tracked.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
trackPages(doTrack: boolean): AnalyticsProvider;
/**
* @summary Sets the URL prefix.
* @param {string} prefix The URL prefix.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
trackPrefix(prefix: string): AnalyticsProvider;
/**
* @summary Track all URL query parameters.
* @param {boolean} val If true, all URL query parameters are tracked.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
trackUrlParams(val: boolean): AnalyticsProvider;
/**
* @summary Use Classic Analytics.
* @param {boolean} val If true, use classic analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useAnalytics(val: boolean): AnalyticsProvider;
/**
* @summary Use Cross Domain Linking.
* @param {boolean} val If true, the cross-linked domains are registered with Google Analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useCrossDomainLinker(val: boolean): AnalyticsProvider;
/**
* @summary Use Display Features.
* @param {boolean} val If true, the display features module is loaded with Google Analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useDisplayFeatures(val: boolean): AnalyticsProvider;
/**
* @summary Enable enhanced e-commerce module.
* @param {boolean} val If true, the enhanced e-commerce module is enabled.
* @param {boolean} enhanced If true, the "ec.js" file is used, otherwises, the "ecommerce.js" is used.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useECommerce(val: boolean, enhanced: boolean): AnalyticsProvider;
/**
* @summary Use Enhanced Link Attribution.
* @param {boolean} val If true, the enhanced link attribution module is loaded with Google Analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useEnhancedLinkAttribution(val: boolean): AnalyticsProvider;
}
}
+59
View File
@@ -0,0 +1,59 @@
/// <reference path="helmet.d.ts" />
import helmet = require("helmet");
/**
* @summary Test for {@see helmet}.
*/
function helmetTest() {
helmet();
}
/**
* @summary Test for {@see helmet#xssFilter} function.
*/
function contentSecurityPolicyTest() {
helmet.xssFilter();
helmet.xssFilter({ setOnOldIE: true });
}
/**
* @summary Test for {@see helmet#frameguard} function.
*/
function frameguardTest() {
helmet.frameguard();
helmet.frameguard("sameorigin");
}
/**
* @summary Test for {@see helmet#hsts} function.
*/
function hstsTest() {
helmet.hsts();
helmet.hsts({ maxAge: 7776000000 });
}
/**
* @summary Test for {@see helmet#ieNoOpen} function.
*/
function ieNoOpenTest() {
helmet.ieNoOpen();
}
/**
* @summary Test for {@see helmet#noSniff} function.
*/
function noSniffTest() {
helmet.noSniff();
}
/**
* @summary Test for {@see helmet#publicKeyPins} function.
*/
function publicKeyPinsTest() {
helmet.publicKeyPins({
sha256s: ["AbCdEf123=", "ZyXwVu456="],
includeSubdomains: true,
reportUri: "http://example.com"
});
}
+57
View File
@@ -0,0 +1,57 @@
// Type definitions for helmet
// Project: https://github.com/helmetjs/helmet
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Helmet {
(): void;
/**
* @summary Prevent clickjacking.
* @param {string} header The header.
*/
frameguard(header ?: string): void;
/**
* @summary Hide "X-Powered-By" header.
* @param {Object} options The options.
*/
hidePoweredBy(options ?: Object): void;
/**
* @summary Adds the "Strict-Transport-Security" header.
* @param {Object} options The options.
*/
hsts(options ?: Object): void;
/**
* @summary Add the "X-Download-Options" header.
*/
ieNoOpen(): void;
/**
* @summary Add the "Cache-Control" and "Pragma" headers to stop caching.
*/
nocache(options ?: Object): void;
/**
* @summary Adds the "X-Content-Type-Options" header.
*/
noSniff(): void;
/**
* @summary Adds the "Public-Key-Pins" header.
*/
publicKeyPins(options ?: Object): void;
/**
* @summary Prevent Cross-site scripting attacks.
* @param {Object} options The options.
*/
xssFilter(options ?: Object): void;
}
declare module "helmet" {
var helmet: Helmet;
export = helmet;
}