<commit_before>var iaplight = (function(){
    
	var protectedInterface = {};

    /*
     * inAppPurchase.getProducts(["com.mycompany.myproduct.weekly.v1"]).then(function(res){console.log("res:"+JSON.stringify(res))})
     * res:[
     *     {
     *         "productId": "com.mycompany.myproduct.weekly.v1",
     *         "title": "Abbonamento Premium CalcioStar Italia",
     *         "description": "Abonamento premium al catalogo CalcioStar Italia",
     *         "price": "€0,99"
     *     }
     * ]
     * 
     * inAppPurchase.subscribe("com.mycompany.myproduct.weekly.v1").then(function(res){console.log("res:"+JSON.stringify(res))}).catch(function(err){console.error(err)})
     * res:{
     *     "transactionId":"1000000221696692",
     *     "receipt":"MXXXX"
     * }
     * 
     * inAppPurchase.getReceiptBundle().then(function(res){console.log("res:"+JSON.stringify(res))})
     * res:{
     *     "originalAppVersion": "1.0",
     *     "appVersion": "0.1.0",
     *     "inAppPurchases": [
     *         {
     *             "transactionIdentifier":"1000000221696692",
     *             "quantity":1,
     *             "purchaseDate":"2016-07-05T10:15:21Z",
     *             "productId":"com.mycompany.myproduct.weekly.v1",
     *             "originalPurchaseDate":"2016-07-05T10:15:22Z",
     *             "subscriptionExpirationDate":"2016-07-05T10:18:21Z",
     *             "originalTransactionIdentifier":"1000000221696692",
     *             "webOrderLineItemID":-1497665198,
     *             "cancellationDate":null}
     *     ],
     *     "bundleIdentifier": "com.mycompany.myproduct"
     * }
    */

    /**
     * 
     * Initialization promise generated from window.inAppPurchase.getProducts
     * all public interface wait for this promise to resolve
     * 
     */
    var initPromise = null;
    

    /**
     * Array of in app products id requested by webapp
     */
    var productsId = [];

    /**
     * Array of in app product information, like this: 
     * [{
     *   "productId": "com.mycompany.myproduct.weekly.v1",
     *   "title": "Premium subscription to myproduct",
     *   "description": "Premium subscription to my beatiful product",
     *   "price": "€0,99"
     * }]
     */
    var productsInfo = [];

    /**
     * @param {object} initializeConf - configuration sent by
     * @return {boolean} - true if init ok
     */
	protectedInterface.initialize = function(initializeConf) {

        if (!window.inAppPurchase) {
            return Promise.reject("inAppPurchase not available, missing cordova plugin.");
        }

        if (initPromise !== null) {
            return initPromise;
        }

        if (initializeConf.productsIdAndroid || initializeConf.productsIdIos) {
            if (isRunningOnAndroid()) {
                productsId = initializeConf.productsIdAndroid;
            }
            else if (isRunningOnIos()) {
                productsId = initializeConf.productsIdIos;
            }
        }

        if (!productsId) {
            return Promise.reject("missing parameter productsId(Android|Ios)");
        }
        if (productsId && productsId.constructor !== Array) {
            return Promise.reject("parameter error, productsId(Android|Ios) must be an array");
        }
        if (productsId.length === 0) {
            return Promise.reject("parameter error, productsId(Android|Ios) must contains at least a productid");
        }
        

        initPromise = window.inAppPurchase.getProducts(productsId)
            .then(function(res){
                productsInfo = res;
                log("[IAPlight] getProducts ok", res);
                return res;
            })
            .catch(function(error) {
                err("[IAPlight] getProducts KO", error);
            });

        return initPromise;
    };

    protectedInterface.subscribe = function(productId) {
        
        if (initPromise === null) {
            return Promise.reject("Not initialized");
        }

        var subFunc = function() {
            return window.inAppPurchase.subscribe(
                productId
            )
            .then(function(res){
                log("[IAPlight] subscribe ok", res);

                if (isRunningOnIos()) {
                    return protectedInterface.getActiveSubscriptionsInfo();
                }

                return res;
            })
            .catch(function(error){
                err("[IAPlight] subscribe KO: "+error, error);
                throw err;
            });
        };

        // wait for initPromise if it didn't complete
        return initPromise.then(subFunc);
    };<commit_msg>new getActiveSubscriptionsInfo method and subscribe for ios with decoded receipt<commit_after>var iaplight = (function(){
    
	var protectedInterface = {};

    /*
     * inAppPurchase.getProducts(["com.mycompany.myproduct.weekly.v1"]).then(function(res){console.log("res:"+JSON.stringify(res))})
     * res:[
     *     {
     *         "productId": "com.mycompany.myproduct.weekly.v1",
     *         "title": "Abbonamento Premium CalcioStar Italia",
     *         "description": "Abonamento premium al catalogo CalcioStar Italia",
     *         "price": "€0,99"
     *     }
     * ]
     * 
     * inAppPurchase.subscribe("com.mycompany.myproduct.weekly.v1").then(function(res){console.log("res:"+JSON.stringify(res))}).catch(function(err){console.error(err)})
     * res:{
     *     "transactionId":"1000000221696692",
     *     "receipt":"MXXXX"
     * }
     * 
     * inAppPurchase.getReceiptBundle().then(function(res){console.log("res:"+JSON.stringify(res))})
     * res:{
     *     "originalAppVersion": "1.0",
     *     "appVersion": "0.1.0",
     *     "inAppPurchases": [
     *         {
     *             "transactionIdentifier":"1000000221696692",
     *             "quantity":1,
     *             "purchaseDate":"2016-07-05T10:15:21Z",
     *             "productId":"com.mycompany.myproduct.weekly.v1",
     *             "originalPurchaseDate":"2016-07-05T10:15:22Z",
     *             "subscriptionExpirationDate":"2016-07-05T10:18:21Z",
     *             "originalTransactionIdentifier":"1000000221696692",
     *             "webOrderLineItemID":-1497665198,
     *             "cancellationDate":null}
     *     ],
     *     "bundleIdentifier": "com.mycompany.myproduct"
     * }
    */

    /**
     * 
     * Initialization promise generated from window.inAppPurchase.getProducts
     * all public interface wait for this promise to resolve
     * 
     */
    var initPromise = null;
    

    /**
     * Array of in app products id requested by webapp
     */
    var productsId = [];

    /**
     * Array of in app product information, like this: 
     * [{
     *   "productId": "com.mycompany.myproduct.weekly.v1",
     *   "title": "Premium subscription to myproduct",
     *   "description": "Premium subscription to my beatiful product",
     *   "price": "€0,99"
     * }]
     */
    var productsInfo = [];

    /**
     * @param {object} initializeConf - configuration sent by
     * @return {boolean} - true if init ok
     */
	protectedInterface.initialize = function(initializeConf) {

        if (!window.inAppPurchase) {
            return Promise.reject("inAppPurchase not available, missing cordova plugin.");
        }

        if (initPromise !== null) {
            return initPromise;
        }

        if (initializeConf.productsIdAndroid || initializeConf.productsIdIos) {
            if (isRunningOnAndroid()) {
                productsId = initializeConf.productsIdAndroid;
            }
            else if (isRunningOnIos()) {
                productsId = initializeConf.productsIdIos;
            }
        }

        if (!productsId) {
            return Promise.reject("missing parameter productsId(Android|Ios)");
        }
        if (productsId && productsId.constructor !== Array) {
            return Promise.reject("parameter error, productsId(Android|Ios) must be an array");
        }
        if (productsId.length === 0) {
            return Promise.reject("parameter error, productsId(Android|Ios) must contains at least a productid");
        }
        

        initPromise = window.inAppPurchase.getProducts(productsId)
            .then(function(res){
                productsInfo = res;
                log("[IAPlight] getProducts ok", res);
                return res;
            })
            .catch(function(error) {
                err("[IAPlight] getProducts KO", error);
            });

        return initPromise;
    };

    protectedInterface.subscribe = function(productId) {
        
        if (initPromise === null) {
            return Promise.reject("Not initialized");
        }

        var subFunc = function() {
            return window.inAppPurchase.subscribe(
                productId
            )
            .then(function(res){
                log("[IAPlight] subscribe ok", res);

                if (isRunningOnIos()) {
                    return protectedInterface.getActiveSubscriptionsInfo()
                    .then(function(resIos){

                        return resIos[productId];
                    });
                }

                return res;
            })
            .catch(function(error){
                err("[IAPlight] subscribe KO: "+error, error);
                throw err;
            });
        };

        // wait for initPromise if it didn't complete
        return initPromise.then(subFunc);
    };
{'fraction_non_alphanumeric': 0.12648387435655006, 'fraction_numerical': 0.02479252022271247, 'mean_word_length': 1.869198312236287, 'pattern_counts': {'":': 46, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2045397', 'n_tokens_mistral': 2838, 'n_tokens_neox': 2618, 'n_words': 472}