<commit_before>/*
 * D2LValence package, js api.
 *
 * Copyright (c) 2012 Desire2Learn Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the license at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

/**
 * This library provides helper classes and functions for use with the Valence
 * Learning Framework API.
 *
 * @fileOverview D2L API JS Library
 * @author <NAME> <<EMAIL>>
 */


/**
 * General namespace value for use with the client SDK.
 *
 * @namespace
 * @this {D2L}
 */
var D2L = D2L || {};

/**
 * This namespace holds service-specific static values and utility functions.
 *
 * @namespace
 * @this {D2L.Auth}
 */
D2L.Auth = {

	// Application auth parameters
	APP_AUTH_ID_PARAM : 'x_a',
	APP_AUTH_KEY_PARAM : 'x_b',
	CALLBACK_PARAM : 'x_target',

	// Operation parameters
	APP_ID_PARAM : 'x_a',
	TOKEN_ID_PARAM : 'x_b',
	SIGNED_APP_PARAM : 'x_c',
	SIGNED_TOKEN_PARAM : 'x_d',

	TIMESTAMP_PARAM : 'x_t',

	AUTH_URL : '/d2l/auth/api/token',

	/**
	 * Determine if an URL is decorated with an application context.
	 *
	 * @param {String} url URL to test
	 *
	 * @return {Boolean} True if URL has an embedded app ID paramter; otherwise, false.
	 */
	isAuthenticated : function (url) {
		if (D2L.Util.parseFromUrl(APP_ID_PARAM, url) !== '') {
			return true;
		} else {
			return false;
		}
	}

};

/**
 * This namespace holds utility functions for encoding, reading, and signing URLs.
 *
 * @namespace
 * @this {D2L.Util}
 */
D2L.Util = {

	/**
	 * Build a full URL for making a Learning Framework API call from its components.
	 *
	 * This function takes a target web service host and constructs a full URL
	 * including the Desire2Learn server address, authentication web-service
	 * path, and target path to be used to authenticate the target request.
	 *
	 * @param {String} host Protocol and host for the URL (for example, 'http://some.host.com').
	 * @param {String} path API route on the host (for example, '/d2l/api/versions').
	 * @param {Number} port Port number on which the service supports the API (for example, '8080').
	 * @param {Array} parameters Array of key-value pairs to append as
	 * parameters to the URL.<commit_msg>(fix) bad reference to APP_ID_PARAM. isAuthenticated obviously never worked<commit_after>/*
 * D2LValence package, js api.
 *
 * Copyright (c) 2012 Desire2Learn Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the license at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

/**
 * This library provides helper classes and functions for use with the Valence
 * Learning Framework API.
 *
 * @fileOverview D2L API JS Library
 * @author <NAME> <<EMAIL>>
 */


/**
 * General namespace value for use with the client SDK.
 *
 * @namespace
 * @this {D2L}
 */
var D2L = D2L || {};

/**
 * This namespace holds service-specific static values and utility functions.
 *
 * @namespace
 * @this {D2L.Auth}
 */
D2L.Auth = {

	// Application auth parameters
	APP_AUTH_ID_PARAM : 'x_a',
	APP_AUTH_KEY_PARAM : 'x_b',
	CALLBACK_PARAM : 'x_target',

	// Operation parameters
	APP_ID_PARAM : 'x_a',
	TOKEN_ID_PARAM : 'x_b',
	SIGNED_APP_PARAM : 'x_c',
	SIGNED_TOKEN_PARAM : 'x_d',

	TIMESTAMP_PARAM : 'x_t',

	AUTH_URL : '/d2l/auth/api/token',

	/**
	 * Determine if an URL is decorated with an application context.
	 *
	 * @param {String} url URL to test
	 *
	 * @return {Boolean} True if URL has an embedded app ID paramter; otherwise, false.
	 */
	isAuthenticated : function (url) {
		if (D2L.Util.parseFromUrl(D2L.Auth.APP_ID_PARAM, url) !== '') {
			return true;
		} else {
			return false;
		}
	}

};

/**
 * This namespace holds utility functions for encoding, reading, and signing URLs.
 *
 * @namespace
 * @this {D2L.Util}
 */
D2L.Util = {

	/**
	 * Build a full URL for making a Learning Framework API call from its components.
	 *
	 * This function takes a target web service host and constructs a full URL
	 * including the Desire2Learn server address, authentication web-service
	 * path, and target path to be used to authenticate the target request.
	 *
	 * @param {String} host Protocol and host for the URL (for example, 'http://some.host.com').
	 * @param {String} path API route on the host (for example, '/d2l/api/versions').
	 * @param {Number} port Port number on which the service supports the API (for example, '8080').
	 * @param {Array} parameters Array of key-value pairs to append as
	 * parameters to the URL.
{'fraction_non_alphanumeric': 0.10597156398104265, 'fraction_numerical': 0.01004739336492891, 'mean_word_length': 3.5094017094017094, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2075852', 'n_tokens_mistral': 1680, 'n_tokens_neox': 1580, 'n_words': 637}