mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
save
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var config;
|
||||
|
||||
function Config(xhr) {
|
||||
function loadPreferences(xhr) {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(xhr.responseText, "application/xml");
|
||||
|
||||
var preferences = doc.getElementsByTagName("preference");
|
||||
return Array.prototype.slice.call(preferences);
|
||||
}
|
||||
|
||||
this.xhr = xhr;
|
||||
this.preferences = loadPreferences(this.xhr);
|
||||
}
|
||||
|
||||
function readConfig(success, error) {
|
||||
var xhr;
|
||||
|
||||
if(typeof config != 'undefined') {
|
||||
success(config);
|
||||
}
|
||||
|
||||
function fail(msg) {
|
||||
console.error(msg);
|
||||
|
||||
if(error) {
|
||||
error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
var xhrStatusChangeHandler = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status == 200 || xhr.status == 304 || xhr.status === 0 /* file:// */) {
|
||||
config = new Config(xhr);
|
||||
success(config);
|
||||
}
|
||||
else {
|
||||
fail('[Browser][cordova.js][xhrStatusChangeHandler] Could not XHR config.xml: ' + xhr.statusText);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.addEventListener("load", xhrStatusChangeHandler);
|
||||
|
||||
|
||||
try {
|
||||
xhr.open("get", "config.xml", true);
|
||||
xhr.send();
|
||||
} catch(e) {
|
||||
fail('[Browser][cordova.js][readConfig] Could not XHR config.xml: ' + JSON.stringify(e));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a preference value from config.xml.
|
||||
* Returns preference value or undefined if it does not exist.
|
||||
* @param {String} preferenceName Preference name to read */
|
||||
Config.prototype.getPreferenceValue = function getPreferenceValue(preferenceName) {
|
||||
var preferenceItem = this.preferences && this.preferences.filter(function(item) {
|
||||
return item.attributes.name && item.attributes.name.value === preferenceName;
|
||||
});
|
||||
|
||||
if(preferenceItem && preferenceItem[0] && preferenceItem[0].attributes && preferenceItem[0].attributes.value) {
|
||||
return preferenceItem[0].attributes.value.value;
|
||||
}
|
||||
};
|
||||
|
||||
exports.readConfig = readConfig;
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true, plusplus:true*/
|
||||
/*global require, module, console */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var execProxy = require('cordova/exec/proxy');
|
||||
|
||||
/**
|
||||
* Execute a cordova command. It is up to the native side whether this action
|
||||
* is synchronous or asynchronous. The native side can return:
|
||||
* Synchronous: PluginResult object as a JSON string
|
||||
* Asynchronous: Empty string ""
|
||||
* If async, the native side will cordova.callbackSuccess or cordova.callbackError,
|
||||
* depending upon the result of the action.
|
||||
*
|
||||
* @param {Function} success The success callback
|
||||
* @param {Function} fail The fail callback
|
||||
* @param {String} service The name of the service to use
|
||||
* @param {String} action Action to be run in cordova
|
||||
* @param {String[]} [args] Zero or more arguments to pass to the method
|
||||
*/
|
||||
module.exports = function (success, fail, service, action, args) {
|
||||
|
||||
var proxy = execProxy.get(service, action);
|
||||
|
||||
args = args || [];
|
||||
|
||||
if (proxy) {
|
||||
|
||||
var callbackId = service + cordova.callbackId++;
|
||||
|
||||
if (typeof success === "function" || typeof fail === "function") {
|
||||
cordova.callbacks[callbackId] = {success: success, fail: fail};
|
||||
}
|
||||
try {
|
||||
|
||||
|
||||
|
||||
// callbackOptions param represents additional optional parameters command could pass back, like keepCallback or
|
||||
// custom callbackId, for example {callbackId: id, keepCallback: true, status: cordova.callbackStatus.JSON_EXCEPTION }
|
||||
var onSuccess = function (result, callbackOptions) {
|
||||
callbackOptions = callbackOptions || {};
|
||||
var callbackStatus;
|
||||
// covering both undefined and null.
|
||||
// strict null comparison was causing callbackStatus to be undefined
|
||||
// and then no callback was called because of the check in cordova.callbackFromNative
|
||||
// see CB-8996 Mobilespec app hang on windows
|
||||
if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
|
||||
callbackStatus = callbackOptions.status;
|
||||
}
|
||||
else {
|
||||
callbackStatus = cordova.callbackStatus.OK;
|
||||
}
|
||||
cordova.callbackSuccess(callbackOptions.callbackId || callbackId,
|
||||
{
|
||||
status: callbackStatus,
|
||||
message: result,
|
||||
keepCallback: callbackOptions.keepCallback || false
|
||||
});
|
||||
};
|
||||
var onError = function (err, callbackOptions) {
|
||||
callbackOptions = callbackOptions || {};
|
||||
var callbackStatus;
|
||||
// covering both undefined and null.
|
||||
// strict null comparison was causing callbackStatus to be undefined
|
||||
// and then no callback was called because of the check in cordova.callbackFromNative
|
||||
// note: status can be 0
|
||||
if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
|
||||
callbackStatus = callbackOptions.status;
|
||||
}
|
||||
else {
|
||||
callbackStatus = cordova.callbackStatus.OK;
|
||||
}
|
||||
cordova.callbackError(callbackOptions.callbackId || callbackId,
|
||||
{
|
||||
status: callbackStatus,
|
||||
message: err,
|
||||
keepCallback: callbackOptions.keepCallback || false
|
||||
});
|
||||
};
|
||||
proxy(onSuccess, onError, args);
|
||||
|
||||
} catch (e) {
|
||||
console.log("Exception calling native with command :: " + service + " :: " + action + " ::exception=" + e);
|
||||
}
|
||||
} else {
|
||||
|
||||
console.log("Error: exec proxy not found for :: " + service + " :: " + action);
|
||||
|
||||
if(typeof fail === "function" ) {
|
||||
fail("Missing Command Error");
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
id: 'browser',
|
||||
cordovaVersion: '4.2.0', // cordova-js
|
||||
|
||||
bootstrap: function() {
|
||||
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var channel = require('cordova/channel');
|
||||
|
||||
modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
|
||||
|
||||
channel.onNativeReady.fire();
|
||||
|
||||
document.addEventListener("visibilitychange", function(){
|
||||
if(document.hidden) {
|
||||
channel.onPause.fire();
|
||||
}
|
||||
else {
|
||||
channel.onResume.fire();
|
||||
}
|
||||
});
|
||||
|
||||
// End of bootstrap
|
||||
}
|
||||
};
|
||||
+1594
File diff suppressed because it is too large
Load Diff
+388
@@ -0,0 +1,388 @@
|
||||
cordova.define('cordova/plugin_list', function(require, exports, module) {
|
||||
module.exports = [
|
||||
{
|
||||
"file": "plugins/cordova-plugin-camera/www/CameraConstants.js",
|
||||
"id": "cordova-plugin-camera.Camera",
|
||||
"pluginId": "cordova-plugin-camera",
|
||||
"clobbers": [
|
||||
"Camera"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js",
|
||||
"id": "cordova-plugin-camera.CameraPopoverOptions",
|
||||
"pluginId": "cordova-plugin-camera",
|
||||
"clobbers": [
|
||||
"CameraPopoverOptions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-camera/www/Camera.js",
|
||||
"id": "cordova-plugin-camera.camera",
|
||||
"pluginId": "cordova-plugin-camera",
|
||||
"clobbers": [
|
||||
"navigator.camera"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-camera/src/browser/CameraProxy.js",
|
||||
"id": "cordova-plugin-camera.CameraProxy",
|
||||
"pluginId": "cordova-plugin-camera",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-device/www/device.js",
|
||||
"id": "cordova-plugin-device.device",
|
||||
"pluginId": "cordova-plugin-device",
|
||||
"clobbers": [
|
||||
"device"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-device/src/browser/DeviceProxy.js",
|
||||
"id": "cordova-plugin-device.DeviceProxy",
|
||||
"pluginId": "cordova-plugin-device",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-dialogs/www/notification.js",
|
||||
"id": "cordova-plugin-dialogs.notification",
|
||||
"pluginId": "cordova-plugin-dialogs",
|
||||
"merges": [
|
||||
"navigator.notification"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-dialogs/www/browser/notification.js",
|
||||
"id": "cordova-plugin-dialogs.notification_browser",
|
||||
"pluginId": "cordova-plugin-dialogs",
|
||||
"merges": [
|
||||
"navigator.notification"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/DirectoryEntry.js",
|
||||
"id": "cordova-plugin-file.DirectoryEntry",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.DirectoryEntry"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/DirectoryReader.js",
|
||||
"id": "cordova-plugin-file.DirectoryReader",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.DirectoryReader"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/Entry.js",
|
||||
"id": "cordova-plugin-file.Entry",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.Entry"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/File.js",
|
||||
"id": "cordova-plugin-file.File",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.File"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/FileEntry.js",
|
||||
"id": "cordova-plugin-file.FileEntry",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.FileEntry"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/FileError.js",
|
||||
"id": "cordova-plugin-file.FileError",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.FileError"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/FileReader.js",
|
||||
"id": "cordova-plugin-file.FileReader",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.FileReader"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/FileSystem.js",
|
||||
"id": "cordova-plugin-file.FileSystem",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.FileSystem"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/FileUploadOptions.js",
|
||||
"id": "cordova-plugin-file.FileUploadOptions",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.FileUploadOptions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/FileUploadResult.js",
|
||||
"id": "cordova-plugin-file.FileUploadResult",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.FileUploadResult"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/FileWriter.js",
|
||||
"id": "cordova-plugin-file.FileWriter",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.FileWriter"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/Flags.js",
|
||||
"id": "cordova-plugin-file.Flags",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.Flags"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/LocalFileSystem.js",
|
||||
"id": "cordova-plugin-file.LocalFileSystem",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.LocalFileSystem"
|
||||
],
|
||||
"merges": [
|
||||
"window"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/Metadata.js",
|
||||
"id": "cordova-plugin-file.Metadata",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.Metadata"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/ProgressEvent.js",
|
||||
"id": "cordova-plugin-file.ProgressEvent",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.ProgressEvent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/fileSystems.js",
|
||||
"id": "cordova-plugin-file.fileSystems",
|
||||
"pluginId": "cordova-plugin-file"
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/requestFileSystem.js",
|
||||
"id": "cordova-plugin-file.requestFileSystem",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"clobbers": [
|
||||
"window.requestFileSystem"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js",
|
||||
"id": "cordova-plugin-file.resolveLocalFileSystemURI",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"merges": [
|
||||
"window"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/browser/isChrome.js",
|
||||
"id": "cordova-plugin-file.isChrome",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/browser/Preparing.js",
|
||||
"id": "cordova-plugin-file.Preparing",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/src/browser/FileProxy.js",
|
||||
"id": "cordova-plugin-file.browserFileProxy",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/fileSystemPaths.js",
|
||||
"id": "cordova-plugin-file.fileSystemPaths",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"merges": [
|
||||
"cordova"
|
||||
],
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-file/www/browser/FileSystem.js",
|
||||
"id": "cordova-plugin-file.firefoxFileSystem",
|
||||
"pluginId": "cordova-plugin-file",
|
||||
"merges": [
|
||||
"window.FileSystem"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-fingerprint-aio/www/Fingerprint.js",
|
||||
"id": "cordova-plugin-fingerprint-aio.Fingerprint",
|
||||
"pluginId": "cordova-plugin-fingerprint-aio",
|
||||
"clobbers": [
|
||||
"Fingerprint"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-globalization/www/GlobalizationError.js",
|
||||
"id": "cordova-plugin-globalization.GlobalizationError",
|
||||
"pluginId": "cordova-plugin-globalization",
|
||||
"clobbers": [
|
||||
"window.GlobalizationError"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-globalization/www/globalization.js",
|
||||
"id": "cordova-plugin-globalization.globalization",
|
||||
"pluginId": "cordova-plugin-globalization",
|
||||
"clobbers": [
|
||||
"navigator.globalization"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-globalization/www/browser/moment.js",
|
||||
"id": "cordova-plugin-globalization.moment",
|
||||
"pluginId": "cordova-plugin-globalization",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-globalization/src/browser/GlobalizationProxy.js",
|
||||
"id": "cordova-plugin-globalization.GlobalizationProxy",
|
||||
"pluginId": "cordova-plugin-globalization",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-inappbrowser/www/inappbrowser.js",
|
||||
"id": "cordova-plugin-inappbrowser.inappbrowser",
|
||||
"pluginId": "cordova-plugin-inappbrowser",
|
||||
"clobbers": [
|
||||
"cordova.InAppBrowser.open"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js",
|
||||
"id": "cordova-plugin-inappbrowser.InAppBrowserProxy",
|
||||
"pluginId": "cordova-plugin-inappbrowser",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-ionic-webview/src/www/util.js",
|
||||
"id": "cordova-plugin-ionic-webview.IonicWebView",
|
||||
"pluginId": "cordova-plugin-ionic-webview",
|
||||
"clobbers": [
|
||||
"Ionic.WebView"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-mfp/src/browser/bootstrap.js",
|
||||
"id": "cordova-plugin-mfp.mfp",
|
||||
"pluginId": "cordova-plugin-mfp",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js",
|
||||
"id": "cordova-plugin-splashscreen.SplashScreen",
|
||||
"pluginId": "cordova-plugin-splashscreen",
|
||||
"clobbers": [
|
||||
"navigator.splashscreen"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-splashscreen/src/browser/SplashScreenProxy.js",
|
||||
"id": "cordova-plugin-splashscreen.SplashScreenProxy",
|
||||
"pluginId": "cordova-plugin-splashscreen",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
|
||||
"id": "cordova-plugin-statusbar.statusbar",
|
||||
"pluginId": "cordova-plugin-statusbar",
|
||||
"clobbers": [
|
||||
"window.StatusBar"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-statusbar/src/browser/StatusBarProxy.js",
|
||||
"id": "cordova-plugin-statusbar.StatusBarProxy",
|
||||
"pluginId": "cordova-plugin-statusbar",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-sqlite-storage/www/SQLitePlugin.js",
|
||||
"id": "cordova-sqlite-storage.SQLitePlugin",
|
||||
"pluginId": "cordova-sqlite-storage",
|
||||
"clobbers": [
|
||||
"SQLitePlugin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-sqlite-storage/node_modules/cordova-sqlite-storage-dependencies/sql-asm-memory-growth.js",
|
||||
"id": "cordova-sqlite-storage.sql",
|
||||
"pluginId": "cordova-sqlite-storage",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-sqlite-storage/src/browser/SQLiteProxy.js",
|
||||
"id": "cordova-sqlite-storage.SQLiteProxy",
|
||||
"pluginId": "cordova-sqlite-storage",
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-screen-orientation/www/screenorientation.js",
|
||||
"id": "cordova-plugin-screen-orientation.screenorientation",
|
||||
"pluginId": "cordova-plugin-screen-orientation",
|
||||
"clobbers": [
|
||||
"cordova.plugins.screenorientation"
|
||||
]
|
||||
}
|
||||
];
|
||||
module.exports.metadata =
|
||||
// TOP OF METADATA
|
||||
{
|
||||
"cordova-plugin-androidx": "3.0.0",
|
||||
"cordova-plugin-androidx-adapter": "1.1.3",
|
||||
"cordova-plugin-camera": "5.0.1",
|
||||
"cordova-plugin-compat": "1.2.0",
|
||||
"cordova-plugin-device": "2.0.3",
|
||||
"cordova-plugin-dialogs": "2.0.2",
|
||||
"cordova-plugin-file": "6.0.2",
|
||||
"cordova-plugin-fingerprint-aio": "4.0.2",
|
||||
"cordova-plugin-globalization": "1.11.0",
|
||||
"cordova-plugin-inappbrowser": "4.1.0",
|
||||
"cordova-plugin-ionic-keyboard": "2.2.0",
|
||||
"cordova-plugin-ionic-webview": "4.2.1",
|
||||
"cordova-plugin-mfp": "8.0.2021031007",
|
||||
"cordova-plugin-mfp-push": "8.0.2021062405",
|
||||
"cordova-plugin-okhttp": "2.0.0",
|
||||
"cordova-plugin-splashscreen": "5.0.4",
|
||||
"cordova-plugin-statusbar": "2.4.3",
|
||||
"cordova-sqlite-storage": "5.1.0",
|
||||
"cordova-plugin-mfp-jsonstore": "8.0.2021062408",
|
||||
"cordova-plugin-screen-orientation": "3.0.2"
|
||||
}
|
||||
// BOTTOM OF METADATA
|
||||
});
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "gabinete digital",
|
||||
"short_name": "gabinete digital",
|
||||
"description": "Description of your app from template",
|
||||
"start_url": "index.html",
|
||||
"scope": "index.html",
|
||||
"icons": [
|
||||
{
|
||||
"src": "img/logo.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "img/splash.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"default_locale": "en",
|
||||
"display": "standalone",
|
||||
"background_color": "#FFF",
|
||||
"theme_color": "#000",
|
||||
"orientation": "landscape"
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
cordova.define("cordova-plugin-camera.CameraProxy", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var HIGHEST_POSSIBLE_Z_INDEX = 2147483647;
|
||||
|
||||
function takePicture (success, error, opts) {
|
||||
if (opts && opts[2] === 1) {
|
||||
capture(success, error, opts);
|
||||
} else {
|
||||
var input = document.createElement('input');
|
||||
input.style.position = 'relative';
|
||||
input.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX;
|
||||
input.className = 'cordova-camera-select';
|
||||
input.type = 'file';
|
||||
input.name = 'files[]';
|
||||
|
||||
input.onchange = function (inputEvent) {
|
||||
var reader = new FileReader(); /* eslint no-undef : 0 */
|
||||
reader.onload = function (readerEvent) {
|
||||
input.parentNode.removeChild(input);
|
||||
|
||||
var imageData = readerEvent.target.result;
|
||||
|
||||
return success(imageData.substr(imageData.indexOf(',') + 1));
|
||||
};
|
||||
|
||||
reader.readAsDataURL(inputEvent.target.files[0]);
|
||||
};
|
||||
|
||||
document.body.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
function capture (success, errorCallback, opts) {
|
||||
var localMediaStream;
|
||||
var targetWidth = opts[3];
|
||||
var targetHeight = opts[4];
|
||||
|
||||
targetWidth = targetWidth === -1 ? 320 : targetWidth;
|
||||
targetHeight = targetHeight === -1 ? 240 : targetHeight;
|
||||
|
||||
var video = document.createElement('video');
|
||||
var button = document.createElement('button');
|
||||
var parent = document.createElement('div');
|
||||
parent.style.position = 'relative';
|
||||
parent.style.zIndex = HIGHEST_POSSIBLE_Z_INDEX;
|
||||
parent.className = 'cordova-camera-capture';
|
||||
parent.appendChild(video);
|
||||
parent.appendChild(button);
|
||||
|
||||
video.width = targetWidth;
|
||||
video.height = targetHeight;
|
||||
button.innerHTML = 'Capture!';
|
||||
|
||||
button.onclick = function () {
|
||||
// create a canvas and capture a frame from video stream
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = targetWidth;
|
||||
canvas.height = targetHeight;
|
||||
canvas.getContext('2d').drawImage(video, 0, 0, targetWidth, targetHeight);
|
||||
|
||||
// convert image stored in canvas to base64 encoded image
|
||||
var imageData = canvas.toDataURL('image/png');
|
||||
imageData = imageData.replace('data:image/png;base64,', '');
|
||||
|
||||
// stop video stream, remove video and button.
|
||||
// Note that MediaStream.stop() is deprecated as of Chrome 47.
|
||||
if (localMediaStream.stop) {
|
||||
localMediaStream.stop();
|
||||
} else {
|
||||
localMediaStream.getTracks().forEach(function (track) {
|
||||
track.stop();
|
||||
});
|
||||
}
|
||||
parent.parentNode.removeChild(parent);
|
||||
|
||||
return success(imageData);
|
||||
};
|
||||
|
||||
navigator.getUserMedia = navigator.getUserMedia ||
|
||||
navigator.webkitGetUserMedia ||
|
||||
navigator.mozGetUserMedia ||
|
||||
navigator.msGetUserMedia;
|
||||
|
||||
var successCallback = function (stream) {
|
||||
localMediaStream = stream;
|
||||
if ('srcObject' in video) {
|
||||
video.srcObject = localMediaStream;
|
||||
} else {
|
||||
video.src = window.URL.createObjectURL(localMediaStream);
|
||||
}
|
||||
video.play();
|
||||
document.body.appendChild(parent);
|
||||
};
|
||||
|
||||
if (navigator.getUserMedia) {
|
||||
navigator.getUserMedia({ video: true, audio: false }, successCallback, errorCallback);
|
||||
} else {
|
||||
alert('Browser does not support camera :(');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
takePicture: takePicture,
|
||||
cleanup: function () {}
|
||||
};
|
||||
|
||||
require('cordova/exec/proxy').add('Camera', module.exports);
|
||||
|
||||
});
|
||||
@@ -0,0 +1,187 @@
|
||||
cordova.define("cordova-plugin-camera.camera", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck');
|
||||
var exec = require('cordova/exec');
|
||||
var Camera = require('./Camera');
|
||||
// XXX: commented out
|
||||
// CameraPopoverHandle = require('./CameraPopoverHandle');
|
||||
|
||||
/**
|
||||
* @namespace navigator
|
||||
*/
|
||||
|
||||
/**
|
||||
* @exports camera
|
||||
*/
|
||||
var cameraExport = {};
|
||||
|
||||
// Tack on the Camera Constants to the base camera plugin.
|
||||
for (var key in Camera) {
|
||||
cameraExport[key] = Camera[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function that provides an error message.
|
||||
* @callback module:camera.onError
|
||||
* @param {string} message - The message is provided by the device's native code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback function that provides the image data.
|
||||
* @callback module:camera.onSuccess
|
||||
* @param {string} imageData - Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`]{@link module:camera.CameraOptions} in effect.
|
||||
* @example
|
||||
* // Show image
|
||||
* //
|
||||
* function cameraCallback(imageData) {
|
||||
* var image = document.getElementById('myImage');
|
||||
* image.src = "data:image/jpeg;base64," + imageData;
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Optional parameters to customize the camera settings.
|
||||
* * [Quirks](#CameraOptions-quirks)
|
||||
* @typedef module:camera.CameraOptions
|
||||
* @type {Object}
|
||||
* @property {number} [quality=50] - Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.)
|
||||
* @property {module:Camera.DestinationType} [destinationType=FILE_URI] - Choose the format of the return value.
|
||||
* @property {module:Camera.PictureSourceType} [sourceType=CAMERA] - Set the source of the picture.
|
||||
* @property {Boolean} [allowEdit=false] - Allow simple editing of image before selection.
|
||||
* @property {module:Camera.EncodingType} [encodingType=JPEG] - Choose the returned image file's encoding.
|
||||
* @property {number} [targetWidth] - Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant.
|
||||
* @property {number} [targetHeight] - Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant.
|
||||
* @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`.
|
||||
* @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture.
|
||||
* @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture.
|
||||
* @property {module:CameraPopoverOptions} [popoverOptions] - iOS-only options that specify popover location in iPad.
|
||||
* @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing).
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Takes a photo using the camera, or retrieves a photo from the device's
|
||||
* image gallery. The image is passed to the success callback as a
|
||||
* Base64-encoded `String`, or as the URI for the image file.
|
||||
*
|
||||
* The `camera.getPicture` function opens the device's default camera
|
||||
* application that allows users to snap pictures by default - this behavior occurs,
|
||||
* when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}.
|
||||
* Once the user snaps the photo, the camera application closes and the application is restored.
|
||||
*
|
||||
* If `Camera.sourceType` is `Camera.PictureSourceType.PHOTOLIBRARY` or
|
||||
* `Camera.PictureSourceType.SAVEDPHOTOALBUM`, then a dialog displays
|
||||
* that allows users to select an existing image.
|
||||
*
|
||||
* The return value is sent to the [`cameraSuccess`]{@link module:camera.onSuccess} callback function, in
|
||||
* one of the following formats, depending on the specified
|
||||
* `cameraOptions`:
|
||||
*
|
||||
* - A `String` containing the Base64-encoded photo image.
|
||||
* - A `String` representing the image file location on local storage (default).
|
||||
*
|
||||
* You can do whatever you want with the encoded image or URI, for
|
||||
* example:
|
||||
*
|
||||
* - Render the image in an `<img>` tag, as in the example below
|
||||
* - Save the data locally (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/), etc.)
|
||||
* - Post the data to a remote server
|
||||
*
|
||||
* __NOTE__: Photo resolution on newer devices is quite good. Photos
|
||||
* selected from the device's gallery are not downscaled to a lower
|
||||
* quality, even if a `quality` parameter is specified. To avoid common
|
||||
* memory problems, set `Camera.destinationType` to `FILE_URI` rather
|
||||
* than `DATA_URL`.
|
||||
*
|
||||
* __Supported Platforms__
|
||||
*
|
||||
* - Android
|
||||
* - BlackBerry
|
||||
* - Browser
|
||||
* - Firefox
|
||||
* - FireOS
|
||||
* - iOS
|
||||
* - Windows
|
||||
* - WP8
|
||||
* - Ubuntu
|
||||
*
|
||||
* More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks).
|
||||
*
|
||||
* @example
|
||||
* navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);
|
||||
* @param {module:camera.onSuccess} successCallback
|
||||
* @param {module:camera.onError} errorCallback
|
||||
* @param {module:camera.CameraOptions} options CameraOptions
|
||||
*/
|
||||
cameraExport.getPicture = function (successCallback, errorCallback, options) {
|
||||
argscheck.checkArgs('fFO', 'Camera.getPicture', arguments);
|
||||
options = options || {};
|
||||
var getValue = argscheck.getValue;
|
||||
|
||||
var quality = getValue(options.quality, 50);
|
||||
var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI);
|
||||
var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA);
|
||||
var targetWidth = getValue(options.targetWidth, -1);
|
||||
var targetHeight = getValue(options.targetHeight, -1);
|
||||
var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG);
|
||||
var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
|
||||
var allowEdit = !!options.allowEdit;
|
||||
var correctOrientation = !!options.correctOrientation;
|
||||
var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
|
||||
var popoverOptions = getValue(options.popoverOptions, null);
|
||||
var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
|
||||
|
||||
var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
|
||||
mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
|
||||
|
||||
exec(successCallback, errorCallback, 'Camera', 'takePicture', args);
|
||||
// XXX: commented out
|
||||
// return new CameraPopoverHandle();
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes intermediate image files that are kept in temporary storage
|
||||
* after calling [`camera.getPicture`]{@link module:camera.getPicture}. Applies only when the value of
|
||||
* `Camera.sourceType` equals `Camera.PictureSourceType.CAMERA` and the
|
||||
* `Camera.destinationType` equals `Camera.DestinationType.FILE_URI`.
|
||||
*
|
||||
* __Supported Platforms__
|
||||
*
|
||||
* - iOS
|
||||
*
|
||||
* @example
|
||||
* navigator.camera.cleanup(onSuccess, onFail);
|
||||
*
|
||||
* function onSuccess() {
|
||||
* console.log("Camera cleanup success.")
|
||||
* }
|
||||
*
|
||||
* function onFail(message) {
|
||||
* alert('Failed because: ' + message);
|
||||
* }
|
||||
*/
|
||||
cameraExport.cleanup = function (successCallback, errorCallback) {
|
||||
exec(successCallback, errorCallback, 'Camera', 'cleanup', []);
|
||||
};
|
||||
|
||||
module.exports = cameraExport;
|
||||
|
||||
});
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
cordova.define("cordova-plugin-camera.Camera", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module Camera
|
||||
*/
|
||||
module.exports = {
|
||||
/**
|
||||
* @description
|
||||
* Defines the output format of `Camera.getPicture` call.
|
||||
*
|
||||
* @enum {number}
|
||||
*/
|
||||
DestinationType: {
|
||||
/** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI if possible */
|
||||
DATA_URL: 0,
|
||||
/** Return file uri (content://media/external/images/media/2 for Android) */
|
||||
FILE_URI: 1
|
||||
},
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
EncodingType: {
|
||||
/** Return JPEG encoded image */
|
||||
JPEG: 0,
|
||||
/** Return PNG encoded image */
|
||||
PNG: 1
|
||||
},
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
MediaType: {
|
||||
/** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */
|
||||
PICTURE: 0,
|
||||
/** Allow selection of video only, ONLY RETURNS URL */
|
||||
VIDEO: 1,
|
||||
/** Allow selection from all media types */
|
||||
ALLMEDIA: 2
|
||||
},
|
||||
/**
|
||||
* @description
|
||||
* Defines the output format of `Camera.getPicture` call.
|
||||
*
|
||||
* @enum {number}
|
||||
*/
|
||||
PictureSourceType: {
|
||||
/** Choose image from the device's photo library (same as SAVEDPHOTOALBUM for Android) */
|
||||
PHOTOLIBRARY: 0,
|
||||
/** Take picture from camera */
|
||||
CAMERA: 1,
|
||||
/** Choose image only from the device's Camera Roll album (same as PHOTOLIBRARY for Android) */
|
||||
SAVEDPHOTOALBUM: 2
|
||||
},
|
||||
/**
|
||||
* Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.
|
||||
* @enum {number}
|
||||
*/
|
||||
PopoverArrowDirection: {
|
||||
ARROW_UP: 1,
|
||||
ARROW_DOWN: 2,
|
||||
ARROW_LEFT: 4,
|
||||
ARROW_RIGHT: 8,
|
||||
ARROW_ANY: 15
|
||||
},
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Direction: {
|
||||
/** Use the back-facing camera */
|
||||
BACK: 0,
|
||||
/** Use the front-facing camera */
|
||||
FRONT: 1
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
cordova.define("cordova-plugin-camera.CameraPopoverOptions", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var Camera = require('./Camera');
|
||||
|
||||
/**
|
||||
* @namespace navigator
|
||||
*/
|
||||
|
||||
/**
|
||||
* iOS-only parameters that specify the anchor element location and arrow
|
||||
* direction of the popover when selecting images from an iPad's library
|
||||
* or album.
|
||||
* Note that the size of the popover may change to adjust to the
|
||||
* direction of the arrow and orientation of the screen. Make sure to
|
||||
* account for orientation changes when specifying the anchor element
|
||||
* location.
|
||||
* @module CameraPopoverOptions
|
||||
* @param {Number} [x=0] - x pixel coordinate of screen element onto which to anchor the popover.
|
||||
* @param {Number} [y=32] - y pixel coordinate of screen element onto which to anchor the popover.
|
||||
* @param {Number} [width=320] - width, in pixels, of the screen element onto which to anchor the popover.
|
||||
* @param {Number} [height=480] - height, in pixels, of the screen element onto which to anchor the popover.
|
||||
* @param {module:Camera.PopoverArrowDirection} [arrowDir=ARROW_ANY] - Direction the arrow on the popover should point.
|
||||
* @param {Number} [popoverWidth=0] - width of the popover (0 or not specified will use apple's default width).
|
||||
* @param {Number} [popoverHeight=0] - height of the popover (0 or not specified will use apple's default height).
|
||||
*/
|
||||
var CameraPopoverOptions = function (x, y, width, height, arrowDir, popoverWidth, popoverHeight) {
|
||||
// information of rectangle that popover should be anchored to
|
||||
this.x = x || 0;
|
||||
this.y = y || 32;
|
||||
this.width = width || 320;
|
||||
this.height = height || 480;
|
||||
this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
|
||||
this.popoverWidth = popoverWidth || 0;
|
||||
this.popoverHeight = popoverHeight || 0;
|
||||
};
|
||||
|
||||
module.exports = CameraPopoverOptions;
|
||||
|
||||
});
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
cordova.define("cordova-plugin-device.DeviceProxy", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
var browser = require('cordova/platform');
|
||||
|
||||
function getPlatform () {
|
||||
return 'browser';
|
||||
}
|
||||
|
||||
function getModel () {
|
||||
return getBrowserInfo(true);
|
||||
}
|
||||
|
||||
function getVersion () {
|
||||
return getBrowserInfo(false);
|
||||
}
|
||||
|
||||
function getBrowserInfo (getModel) {
|
||||
var userAgent = navigator.userAgent;
|
||||
var returnVal = '';
|
||||
var offset;
|
||||
|
||||
if ((offset = userAgent.indexOf('Edge')) !== -1) {
|
||||
returnVal = (getModel) ? 'Edge' : userAgent.substring(offset + 5);
|
||||
} else if ((offset = userAgent.indexOf('Chrome')) !== -1) {
|
||||
returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7);
|
||||
} else if ((offset = userAgent.indexOf('Safari')) !== -1) {
|
||||
if (getModel) {
|
||||
returnVal = 'Safari';
|
||||
} else {
|
||||
returnVal = userAgent.substring(offset + 7);
|
||||
|
||||
if ((offset = userAgent.indexOf('Version')) !== -1) {
|
||||
returnVal = userAgent.substring(offset + 8);
|
||||
}
|
||||
}
|
||||
} else if ((offset = userAgent.indexOf('Firefox')) !== -1) {
|
||||
returnVal = (getModel) ? 'Firefox' : userAgent.substring(offset + 8);
|
||||
} else if ((offset = userAgent.indexOf('MSIE')) !== -1) {
|
||||
returnVal = (getModel) ? 'MSIE' : userAgent.substring(offset + 5);
|
||||
} else if ((offset = userAgent.indexOf('Trident')) !== -1) {
|
||||
returnVal = (getModel) ? 'MSIE' : '11';
|
||||
}
|
||||
|
||||
if ((offset = returnVal.indexOf(';')) !== -1 || (offset = returnVal.indexOf(' ')) !== -1) {
|
||||
returnVal = returnVal.substring(0, offset);
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getDeviceInfo: function (success, error) {
|
||||
setTimeout(function () {
|
||||
success({
|
||||
cordova: browser.cordovaVersion,
|
||||
platform: getPlatform(),
|
||||
model: getModel(),
|
||||
version: getVersion(),
|
||||
uuid: null,
|
||||
isVirtual: false
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
||||
require('cordova/exec/proxy').add('Device', module.exports);
|
||||
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
cordova.define("cordova-plugin-device.device", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck');
|
||||
var channel = require('cordova/channel');
|
||||
var utils = require('cordova/utils');
|
||||
var exec = require('cordova/exec');
|
||||
var cordova = require('cordova');
|
||||
|
||||
channel.createSticky('onCordovaInfoReady');
|
||||
// Tell cordova channel to wait on the CordovaInfoReady event
|
||||
channel.waitForInitialization('onCordovaInfoReady');
|
||||
|
||||
/**
|
||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||
* phone, etc.
|
||||
* @constructor
|
||||
*/
|
||||
function Device () {
|
||||
this.available = false;
|
||||
this.platform = null;
|
||||
this.version = null;
|
||||
this.uuid = null;
|
||||
this.cordova = null;
|
||||
this.model = null;
|
||||
this.manufacturer = null;
|
||||
this.isVirtual = null;
|
||||
this.serial = null;
|
||||
|
||||
var me = this;
|
||||
|
||||
channel.onCordovaReady.subscribe(function () {
|
||||
me.getInfo(function (info) {
|
||||
// ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
|
||||
// TODO: CB-5105 native implementations should not return info.cordova
|
||||
var buildLabel = cordova.version;
|
||||
me.available = true;
|
||||
me.platform = info.platform;
|
||||
me.version = info.version;
|
||||
me.uuid = info.uuid;
|
||||
me.cordova = buildLabel;
|
||||
me.model = info.model;
|
||||
me.isVirtual = info.isVirtual;
|
||||
me.manufacturer = info.manufacturer || 'unknown';
|
||||
me.serial = info.serial || 'unknown';
|
||||
channel.onCordovaInfoReady.fire();
|
||||
}, function (e) {
|
||||
me.available = false;
|
||||
utils.alert('[ERROR] Error initializing Cordova: ' + e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get device info
|
||||
*
|
||||
* @param {Function} successCallback The function to call when the heading data is available
|
||||
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
||||
*/
|
||||
Device.prototype.getInfo = function (successCallback, errorCallback) {
|
||||
argscheck.checkArgs('fF', 'Device.getInfo', arguments);
|
||||
exec(successCallback, errorCallback, 'Device', 'getDeviceInfo', []);
|
||||
};
|
||||
|
||||
module.exports = new Device();
|
||||
|
||||
});
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
cordova.define("cordova-plugin-dialogs.notification_browser", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// Platform: browser
|
||||
window.navigator.notification = window.navigator.notification || {};
|
||||
|
||||
module.exports.alert = window.navigator.notification.alert = function (message, callback) {
|
||||
// `notification.alert` executes asynchronously
|
||||
setTimeout(function () {
|
||||
window.alert(message);
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
|
||||
module.exports.confirm = window.navigator.notification.confirm = function (message, callback) {
|
||||
// `notification.confirm` executes asynchronously
|
||||
/* eslint-disable standard/no-callback-literal */
|
||||
setTimeout(function () {
|
||||
var result = window.confirm(message);
|
||||
if (callback) {
|
||||
if (result) {
|
||||
callback(1); // OK
|
||||
} else {
|
||||
callback(2); // Cancel
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
|
||||
module.exports.prompt = window.navigator.notification.prompt = function (message, callback, title, buttonLabels, defaultText) {
|
||||
// `notification.prompt` executes asynchronously
|
||||
setTimeout(function () {
|
||||
var result = window.prompt(message, defaultText || '');
|
||||
if (callback) {
|
||||
if (result === null) {
|
||||
callback({ buttonIndex: 2, input1: '' }); // Cancel
|
||||
} else {
|
||||
callback({ buttonIndex: 1, input1: result }); // OK
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
/* eslint-enable standard/no-callback-literal */
|
||||
var audioContext = (function () {
|
||||
// Determine if the Audio API is supported by this browser
|
||||
var AudioApi = window.AudioContext;
|
||||
if (!AudioApi) {
|
||||
AudioApi = window.webkitAudioContext;
|
||||
}
|
||||
|
||||
if (AudioApi) {
|
||||
// The Audio API is supported, so create a singleton instance of the AudioContext
|
||||
return new AudioApi();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}());
|
||||
|
||||
module.exports.beep = window.navigator.notification.beep = function (times) {
|
||||
if (times > 0) {
|
||||
var BEEP_DURATION = 700;
|
||||
var BEEP_INTERVAL = 300;
|
||||
|
||||
if (audioContext) {
|
||||
// Start a beep, using the Audio API
|
||||
var osc = audioContext.createOscillator();
|
||||
osc.type = 0; // sounds like a "beep"
|
||||
osc.connect(audioContext.destination);
|
||||
osc.start(0);
|
||||
|
||||
setTimeout(function () {
|
||||
// Stop the beep after the BEEP_DURATION
|
||||
osc.stop(0);
|
||||
|
||||
if (--times > 0) {
|
||||
// Beep again, after a pause
|
||||
setTimeout(function () {
|
||||
navigator.notification.beep(times);
|
||||
}, BEEP_INTERVAL);
|
||||
}
|
||||
|
||||
}, BEEP_DURATION);
|
||||
} else if (typeof (console) !== 'undefined' && typeof (console.log) === 'function') {
|
||||
// Audio API isn't supported, so just write `beep` to the console
|
||||
for (var i = 0; i < times; i++) {
|
||||
console.log('Beep!');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
cordova.define("cordova-plugin-dialogs.notification", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
var platform = require('cordova/platform');
|
||||
|
||||
/**
|
||||
* Provides access to notifications on the device.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* Open a native alert dialog, with a customizable title and button text.
|
||||
*
|
||||
* @param {String} message Message to print in the body of the alert
|
||||
* @param {Function} completeCallback The callback that is called when user clicks on a button.
|
||||
* @param {String} title Title of the alert dialog (default: Alert)
|
||||
* @param {String} buttonLabel Label of the close button (default: OK)
|
||||
*/
|
||||
alert: function (message, completeCallback, title, buttonLabel) {
|
||||
var _message = (typeof message === 'string' ? message : JSON.stringify(message));
|
||||
var _title = (typeof title === 'string' ? title : 'Alert');
|
||||
var _buttonLabel = (buttonLabel && typeof buttonLabel === 'string' ? buttonLabel : 'OK');
|
||||
exec(completeCallback, null, 'Notification', 'alert', [_message, _title, _buttonLabel]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Open a native confirm dialog, with a customizable title and button text.
|
||||
* The result that the user selects is returned to the result callback.
|
||||
*
|
||||
* @param {String} message Message to print in the body of the alert
|
||||
* @param {Function} resultCallback The callback that is called when user clicks on a button.
|
||||
* @param {String} title Title of the alert dialog (default: Confirm)
|
||||
* @param {Array} buttonLabels Array of the labels of the buttons (default: ['OK', 'Cancel'])
|
||||
*/
|
||||
confirm: function (message, resultCallback, title, buttonLabels) {
|
||||
var _message = (typeof message === 'string' ? message : JSON.stringify(message));
|
||||
var _title = (typeof title === 'string' ? title : 'Confirm');
|
||||
var _buttonLabels = (buttonLabels || ['OK', 'Cancel']);
|
||||
|
||||
// Strings are deprecated!
|
||||
if (typeof _buttonLabels === 'string') {
|
||||
console.log('Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).');
|
||||
}
|
||||
|
||||
_buttonLabels = convertButtonLabels(_buttonLabels);
|
||||
|
||||
exec(resultCallback, null, 'Notification', 'confirm', [_message, _title, _buttonLabels]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Open a native prompt dialog, with a customizable title and button text.
|
||||
* The following results are returned to the result callback:
|
||||
* buttonIndex Index number of the button selected.
|
||||
* input1 The text entered in the prompt dialog box.
|
||||
*
|
||||
* @param {String} message Dialog message to display (default: "Prompt message")
|
||||
* @param {Function} resultCallback The callback that is called when user clicks on a button.
|
||||
* @param {String} title Title of the dialog (default: "Prompt")
|
||||
* @param {Array} buttonLabels Array of strings for the button labels (default: ["OK","Cancel"])
|
||||
* @param {String} defaultText Textbox input value (default: empty string)
|
||||
*/
|
||||
prompt: function (message, resultCallback, title, buttonLabels, defaultText) {
|
||||
var _message = (typeof message === 'string' ? message : JSON.stringify(message));
|
||||
var _title = (typeof title === 'string' ? title : 'Prompt');
|
||||
var _buttonLabels = (buttonLabels || ['OK', 'Cancel']);
|
||||
|
||||
// Strings are deprecated!
|
||||
if (typeof _buttonLabels === 'string') {
|
||||
console.log('Notification.prompt(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).');
|
||||
}
|
||||
|
||||
_buttonLabels = convertButtonLabels(_buttonLabels);
|
||||
|
||||
var _defaultText = (defaultText || '');
|
||||
exec(resultCallback, null, 'Notification', 'prompt', [_message, _title, _buttonLabels, _defaultText]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Causes the device to beep.
|
||||
* On Android, the default notification ringtone is played "count" times.
|
||||
*
|
||||
* @param {Integer} count The number of beeps.
|
||||
*/
|
||||
beep: function (count) {
|
||||
var defaultedCount = count || 1;
|
||||
exec(null, null, 'Notification', 'beep', [ defaultedCount ]);
|
||||
}
|
||||
};
|
||||
|
||||
function convertButtonLabels (buttonLabels) {
|
||||
|
||||
// Some platforms take an array of button label names.
|
||||
// Other platforms take a comma separated list.
|
||||
// For compatibility, we convert to the desired type based on the platform.
|
||||
if (platform.id === 'amazon-fireos' || platform.id === 'android' || platform.id === 'ios' ||
|
||||
platform.id === 'windowsphone' || platform.id === 'firefoxos' || platform.id === 'ubuntu' ||
|
||||
platform.id === 'windows8' || platform.id === 'windows') {
|
||||
|
||||
if (typeof buttonLabels === 'string') {
|
||||
buttonLabels = buttonLabels.split(','); // not crazy about changing the var type here
|
||||
}
|
||||
} else {
|
||||
if (Array.isArray(buttonLabels)) {
|
||||
var buttonLabelArray = buttonLabels;
|
||||
buttonLabels = buttonLabelArray.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return buttonLabels;
|
||||
}
|
||||
|
||||
});
|
||||
+1061
File diff suppressed because it is too large
Load Diff
+119
@@ -0,0 +1,119 @@
|
||||
cordova.define("cordova-plugin-file.DirectoryEntry", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck');
|
||||
var utils = require('cordova/utils');
|
||||
var exec = require('cordova/exec');
|
||||
var Entry = require('./Entry');
|
||||
var FileError = require('./FileError');
|
||||
var DirectoryReader = require('./DirectoryReader');
|
||||
|
||||
/**
|
||||
* An interface representing a directory on the file system.
|
||||
*
|
||||
* {boolean} isFile always false (readonly)
|
||||
* {boolean} isDirectory always true (readonly)
|
||||
* {DOMString} name of the directory, excluding the path leading to it (readonly)
|
||||
* {DOMString} fullPath the absolute full path to the directory (readonly)
|
||||
* {FileSystem} filesystem on which the directory resides (readonly)
|
||||
*/
|
||||
var DirectoryEntry = function (name, fullPath, fileSystem, nativeURL) {
|
||||
|
||||
// add trailing slash if it is missing
|
||||
if ((fullPath) && !/\/$/.test(fullPath)) {
|
||||
fullPath += '/';
|
||||
}
|
||||
// add trailing slash if it is missing
|
||||
if (nativeURL && !/\/$/.test(nativeURL)) {
|
||||
nativeURL += '/';
|
||||
}
|
||||
DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem, nativeURL);
|
||||
};
|
||||
|
||||
utils.extend(DirectoryEntry, Entry);
|
||||
|
||||
/**
|
||||
* Creates a new DirectoryReader to read entries from this directory
|
||||
*/
|
||||
DirectoryEntry.prototype.createReader = function () {
|
||||
return new DirectoryReader(this.toInternalURL());
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates or looks up a directory
|
||||
*
|
||||
* @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
|
||||
* @param {Flags} options to create or exclusively create the directory
|
||||
* @param {Function} successCallback is called with the new entry
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) {
|
||||
argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
|
||||
var fs = this.filesystem;
|
||||
var win = successCallback && function (result) {
|
||||
var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL);
|
||||
successCallback(entry);
|
||||
};
|
||||
var fail = errorCallback && function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
exec(win, fail, 'File', 'getDirectory', [this.toInternalURL(), path, options]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Deletes a directory and all of it's contents
|
||||
*
|
||||
* @param {Function} successCallback is called with no parameters
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) {
|
||||
argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
|
||||
var fail = errorCallback && function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
exec(successCallback, fail, 'File', 'removeRecursively', [this.toInternalURL()]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates or looks up a file
|
||||
*
|
||||
* @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
|
||||
* @param {Flags} options to create or exclusively create the file
|
||||
* @param {Function} successCallback is called with the new entry
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback) {
|
||||
argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
|
||||
var fs = this.filesystem;
|
||||
var win = successCallback && function (result) {
|
||||
var FileEntry = require('./FileEntry');
|
||||
var entry = new FileEntry(result.name, result.fullPath, fs, result.nativeURL);
|
||||
successCallback(entry);
|
||||
};
|
||||
var fail = errorCallback && function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
exec(win, fail, 'File', 'getFile', [this.toInternalURL(), path, options]);
|
||||
};
|
||||
|
||||
module.exports = DirectoryEntry;
|
||||
|
||||
});
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
cordova.define("cordova-plugin-file.DirectoryReader", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
var FileError = require('./FileError');
|
||||
|
||||
/**
|
||||
* An interface that lists the files and directories in a directory.
|
||||
*/
|
||||
function DirectoryReader (localURL) {
|
||||
this.localURL = localURL || null;
|
||||
this.hasReadEntries = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of entries from a directory.
|
||||
*
|
||||
* @param {Function} successCallback is called with a list of entries
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
DirectoryReader.prototype.readEntries = function (successCallback, errorCallback) {
|
||||
// If we've already read and passed on this directory's entries, return an empty list.
|
||||
if (this.hasReadEntries) {
|
||||
successCallback([]);
|
||||
return;
|
||||
}
|
||||
var reader = this;
|
||||
var win = typeof successCallback !== 'function' ? null : function (result) {
|
||||
var retVal = [];
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
var entry = null;
|
||||
if (result[i].isDirectory) {
|
||||
entry = new (require('./DirectoryEntry'))();
|
||||
} else if (result[i].isFile) {
|
||||
entry = new (require('./FileEntry'))();
|
||||
}
|
||||
entry.isDirectory = result[i].isDirectory;
|
||||
entry.isFile = result[i].isFile;
|
||||
entry.name = result[i].name;
|
||||
entry.fullPath = result[i].fullPath;
|
||||
entry.filesystem = new (require('./FileSystem'))(result[i].filesystemName);
|
||||
entry.nativeURL = result[i].nativeURL;
|
||||
retVal.push(entry);
|
||||
}
|
||||
reader.hasReadEntries = true;
|
||||
successCallback(retVal);
|
||||
};
|
||||
var fail = typeof errorCallback !== 'function' ? null : function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
exec(win, fail, 'File', 'readEntries', [this.localURL]);
|
||||
};
|
||||
|
||||
module.exports = DirectoryReader;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,262 @@
|
||||
cordova.define("cordova-plugin-file.Entry", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck');
|
||||
var exec = require('cordova/exec');
|
||||
var FileError = require('./FileError');
|
||||
var Metadata = require('./Metadata');
|
||||
|
||||
/**
|
||||
* Represents a file or directory on the local file system.
|
||||
*
|
||||
* @param isFile
|
||||
* {boolean} true if Entry is a file (readonly)
|
||||
* @param isDirectory
|
||||
* {boolean} true if Entry is a directory (readonly)
|
||||
* @param name
|
||||
* {DOMString} name of the file or directory, excluding the path
|
||||
* leading to it (readonly)
|
||||
* @param fullPath
|
||||
* {DOMString} the absolute full path to the file or directory
|
||||
* (readonly)
|
||||
* @param fileSystem
|
||||
* {FileSystem} the filesystem on which this entry resides
|
||||
* (readonly)
|
||||
* @param nativeURL
|
||||
* {DOMString} an alternate URL which can be used by native
|
||||
* webview controls, for example media players.
|
||||
* (optional, readonly)
|
||||
*/
|
||||
function Entry (isFile, isDirectory, name, fullPath, fileSystem, nativeURL) {
|
||||
this.isFile = !!isFile;
|
||||
this.isDirectory = !!isDirectory;
|
||||
this.name = name || '';
|
||||
this.fullPath = fullPath || '';
|
||||
this.filesystem = fileSystem || null;
|
||||
this.nativeURL = nativeURL || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look up the metadata of the entry.
|
||||
*
|
||||
* @param successCallback
|
||||
* {Function} is called with a Metadata object
|
||||
* @param errorCallback
|
||||
* {Function} is called with a FileError
|
||||
*/
|
||||
Entry.prototype.getMetadata = function (successCallback, errorCallback) {
|
||||
argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
|
||||
var success = successCallback && function (entryMetadata) {
|
||||
var metadata = new Metadata({
|
||||
size: entryMetadata.size,
|
||||
modificationTime: entryMetadata.lastModifiedDate
|
||||
});
|
||||
successCallback(metadata);
|
||||
};
|
||||
var fail = errorCallback && function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
exec(success, fail, 'File', 'getFileMetadata', [this.toInternalURL()]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the metadata of the entry.
|
||||
*
|
||||
* @param successCallback
|
||||
* {Function} is called with a Metadata object
|
||||
* @param errorCallback
|
||||
* {Function} is called with a FileError
|
||||
* @param metadataObject
|
||||
* {Object} keys and values to set
|
||||
*/
|
||||
Entry.prototype.setMetadata = function (successCallback, errorCallback, metadataObject) {
|
||||
argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
|
||||
exec(successCallback, errorCallback, 'File', 'setMetadata', [this.toInternalURL(), metadataObject]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Move a file or directory to a new location.
|
||||
*
|
||||
* @param parent
|
||||
* {DirectoryEntry} the directory to which to move this entry
|
||||
* @param newName
|
||||
* {DOMString} new name of the entry, defaults to the current name
|
||||
* @param successCallback
|
||||
* {Function} called with the new DirectoryEntry object
|
||||
* @param errorCallback
|
||||
* {Function} called with a FileError
|
||||
*/
|
||||
Entry.prototype.moveTo = function (parent, newName, successCallback, errorCallback) {
|
||||
argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
|
||||
var fail = errorCallback && function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
var srcURL = this.toInternalURL();
|
||||
// entry name
|
||||
var name = newName || this.name;
|
||||
var success = function (entry) {
|
||||
if (entry) {
|
||||
if (successCallback) {
|
||||
// create appropriate Entry object
|
||||
var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);
|
||||
var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef
|
||||
var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);
|
||||
successCallback(result);
|
||||
}
|
||||
} else {
|
||||
// no Entry object returned
|
||||
if (fail) {
|
||||
fail(FileError.NOT_FOUND_ERR);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// copy
|
||||
exec(success, fail, 'File', 'moveTo', [srcURL, parent.toInternalURL(), name]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Copy a directory to a different location.
|
||||
*
|
||||
* @param parent
|
||||
* {DirectoryEntry} the directory to which to copy the entry
|
||||
* @param newName
|
||||
* {DOMString} new name of the entry, defaults to the current name
|
||||
* @param successCallback
|
||||
* {Function} called with the new Entry object
|
||||
* @param errorCallback
|
||||
* {Function} called with a FileError
|
||||
*/
|
||||
Entry.prototype.copyTo = function (parent, newName, successCallback, errorCallback) {
|
||||
argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
|
||||
var fail = errorCallback && function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
var srcURL = this.toInternalURL();
|
||||
// entry name
|
||||
var name = newName || this.name;
|
||||
// success callback
|
||||
var success = function (entry) {
|
||||
if (entry) {
|
||||
if (successCallback) {
|
||||
// create appropriate Entry object
|
||||
var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);
|
||||
var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef
|
||||
var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);
|
||||
successCallback(result);
|
||||
}
|
||||
} else {
|
||||
// no Entry object returned
|
||||
if (fail) {
|
||||
fail(FileError.NOT_FOUND_ERR);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// copy
|
||||
exec(success, fail, 'File', 'copyTo', [srcURL, parent.toInternalURL(), name]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a URL that can be passed across the bridge to identify this entry.
|
||||
*/
|
||||
Entry.prototype.toInternalURL = function () {
|
||||
if (this.filesystem && this.filesystem.__format__) {
|
||||
return this.filesystem.__format__(this.fullPath, this.nativeURL);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a URL that can be used to identify this entry.
|
||||
* Use a URL that can be used to as the src attribute of a <video> or
|
||||
* <audio> tag. If that is not possible, construct a cdvfile:// URL.
|
||||
*/
|
||||
Entry.prototype.toURL = function () {
|
||||
if (this.nativeURL) {
|
||||
return this.nativeURL;
|
||||
}
|
||||
// fullPath attribute may contain the full URL in the case that
|
||||
// toInternalURL fails.
|
||||
return this.toInternalURL() || 'file://localhost' + this.fullPath;
|
||||
};
|
||||
|
||||
/**
|
||||
* Backwards-compatibility: In v1.0.0 - 1.0.2, .toURL would only return a
|
||||
* cdvfile:// URL, and this method was necessary to obtain URLs usable by the
|
||||
* webview.
|
||||
* See CB-6051, CB-6106, CB-6117, CB-6152, CB-6199, CB-6201, CB-6243, CB-6249,
|
||||
* and CB-6300.
|
||||
*/
|
||||
Entry.prototype.toNativeURL = function () {
|
||||
console.log("DEPRECATED: Update your code to use 'toURL'");
|
||||
return this.toURL();
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a URI that can be used to identify this entry.
|
||||
*
|
||||
* @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
|
||||
* @return uri
|
||||
*/
|
||||
Entry.prototype.toURI = function (mimeType) {
|
||||
console.log("DEPRECATED: Update your code to use 'toURL'");
|
||||
return this.toURL();
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove a file or directory. It is an error to attempt to delete a
|
||||
* directory that is not empty. It is an error to attempt to delete a
|
||||
* root directory of a file system.
|
||||
*
|
||||
* @param successCallback {Function} called with no parameters
|
||||
* @param errorCallback {Function} called with a FileError
|
||||
*/
|
||||
Entry.prototype.remove = function (successCallback, errorCallback) {
|
||||
argscheck.checkArgs('FF', 'Entry.remove', arguments);
|
||||
var fail = errorCallback && function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
exec(successCallback, fail, 'File', 'remove', [this.toInternalURL()]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Look up the parent DirectoryEntry of this entry.
|
||||
*
|
||||
* @param successCallback {Function} called with the parent DirectoryEntry object
|
||||
* @param errorCallback {Function} called with a FileError
|
||||
*/
|
||||
Entry.prototype.getParent = function (successCallback, errorCallback) {
|
||||
argscheck.checkArgs('FF', 'Entry.getParent', arguments);
|
||||
var fs = this.filesystem;
|
||||
var win = successCallback && function (result) {
|
||||
var DirectoryEntry = require('./DirectoryEntry');
|
||||
var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL);
|
||||
successCallback(entry);
|
||||
};
|
||||
var fail = errorCallback && function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
exec(win, fail, 'File', 'getParent', [this.toInternalURL()]);
|
||||
};
|
||||
|
||||
module.exports = Entry;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,80 @@
|
||||
cordova.define("cordova-plugin-file.File", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* name {DOMString} name of the file, without path information
|
||||
* fullPath {DOMString} the full path of the file, including the name
|
||||
* type {DOMString} mime type
|
||||
* lastModifiedDate {Date} last modified date
|
||||
* size {Number} size of the file in bytes
|
||||
*/
|
||||
|
||||
var File = function (name, localURL, type, lastModifiedDate, size) {
|
||||
this.name = name || '';
|
||||
this.localURL = localURL || null;
|
||||
this.type = type || null;
|
||||
this.lastModified = lastModifiedDate || null;
|
||||
// For backwards compatibility, store the timestamp in lastModifiedDate as well
|
||||
this.lastModifiedDate = lastModifiedDate || null;
|
||||
this.size = size || 0;
|
||||
|
||||
// These store the absolute start and end for slicing the file.
|
||||
this.start = 0;
|
||||
this.end = this.size;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a "slice" of the file. Since Cordova Files don't contain the actual
|
||||
* content, this really returns a File with adjusted start and end.
|
||||
* Slices of slices are supported.
|
||||
* start {Number} The index at which to start the slice (inclusive).
|
||||
* end {Number} The index at which to end the slice (exclusive).
|
||||
*/
|
||||
File.prototype.slice = function (start, end) {
|
||||
var size = this.end - this.start;
|
||||
var newStart = 0;
|
||||
var newEnd = size;
|
||||
if (arguments.length) {
|
||||
if (start < 0) {
|
||||
newStart = Math.max(size + start, 0);
|
||||
} else {
|
||||
newStart = Math.min(size, start);
|
||||
}
|
||||
}
|
||||
|
||||
if (arguments.length >= 2) {
|
||||
if (end < 0) {
|
||||
newEnd = Math.max(size + end, 0);
|
||||
} else {
|
||||
newEnd = Math.min(end, size);
|
||||
}
|
||||
}
|
||||
|
||||
var newFile = new File(this.name, this.localURL, this.type, this.lastModified, this.size);
|
||||
newFile.start = this.start + newStart;
|
||||
newFile.end = this.start + newEnd;
|
||||
return newFile;
|
||||
};
|
||||
|
||||
module.exports = File;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
cordova.define("cordova-plugin-file.FileEntry", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var utils = require('cordova/utils');
|
||||
var exec = require('cordova/exec');
|
||||
var Entry = require('./Entry');
|
||||
var FileWriter = require('./FileWriter');
|
||||
var File = require('./File');
|
||||
var FileError = require('./FileError');
|
||||
|
||||
/**
|
||||
* An interface representing a file on the file system.
|
||||
*
|
||||
* {boolean} isFile always true (readonly)
|
||||
* {boolean} isDirectory always false (readonly)
|
||||
* {DOMString} name of the file, excluding the path leading to it (readonly)
|
||||
* {DOMString} fullPath the absolute full path to the file (readonly)
|
||||
* {FileSystem} filesystem on which the file resides (readonly)
|
||||
*/
|
||||
var FileEntry = function (name, fullPath, fileSystem, nativeURL) {
|
||||
// remove trailing slash if it is present
|
||||
if (fullPath && /\/$/.test(fullPath)) {
|
||||
fullPath = fullPath.substring(0, fullPath.length - 1);
|
||||
}
|
||||
if (nativeURL && /\/$/.test(nativeURL)) {
|
||||
nativeURL = nativeURL.substring(0, nativeURL.length - 1);
|
||||
}
|
||||
|
||||
FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath, fileSystem, nativeURL]);
|
||||
};
|
||||
|
||||
utils.extend(FileEntry, Entry);
|
||||
|
||||
/**
|
||||
* Creates a new FileWriter associated with the file that this FileEntry represents.
|
||||
*
|
||||
* @param {Function} successCallback is called with the new FileWriter
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
FileEntry.prototype.createWriter = function (successCallback, errorCallback) {
|
||||
this.file(function (filePointer) {
|
||||
var writer = new FileWriter(filePointer);
|
||||
|
||||
if (writer.localURL === null || writer.localURL === '') {
|
||||
if (errorCallback) {
|
||||
errorCallback(new FileError(FileError.INVALID_STATE_ERR));
|
||||
}
|
||||
} else {
|
||||
if (successCallback) {
|
||||
successCallback(writer);
|
||||
}
|
||||
}
|
||||
}, errorCallback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a File that represents the current state of the file that this FileEntry represents.
|
||||
*
|
||||
* @param {Function} successCallback is called with the new File object
|
||||
* @param {Function} errorCallback is called with a FileError
|
||||
*/
|
||||
FileEntry.prototype.file = function (successCallback, errorCallback) {
|
||||
var localURL = this.toInternalURL();
|
||||
var win = successCallback && function (f) {
|
||||
var file = new File(f.name, localURL, f.type, f.lastModifiedDate, f.size);
|
||||
successCallback(file);
|
||||
};
|
||||
var fail = errorCallback && function (code) {
|
||||
errorCallback(new FileError(code));
|
||||
};
|
||||
exec(win, fail, 'File', 'getFileMetadata', [localURL]);
|
||||
};
|
||||
|
||||
module.exports = FileEntry;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
cordova.define("cordova-plugin-file.FileError", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* FileError
|
||||
*/
|
||||
function FileError (error) {
|
||||
this.code = error || null;
|
||||
}
|
||||
|
||||
// File error codes
|
||||
// Found in DOMException
|
||||
FileError.NOT_FOUND_ERR = 1;
|
||||
FileError.SECURITY_ERR = 2;
|
||||
FileError.ABORT_ERR = 3;
|
||||
|
||||
// Added by File API specification
|
||||
FileError.NOT_READABLE_ERR = 4;
|
||||
FileError.ENCODING_ERR = 5;
|
||||
FileError.NO_MODIFICATION_ALLOWED_ERR = 6;
|
||||
FileError.INVALID_STATE_ERR = 7;
|
||||
FileError.SYNTAX_ERR = 8;
|
||||
FileError.INVALID_MODIFICATION_ERR = 9;
|
||||
FileError.QUOTA_EXCEEDED_ERR = 10;
|
||||
FileError.TYPE_MISMATCH_ERR = 11;
|
||||
FileError.PATH_EXISTS_ERR = 12;
|
||||
|
||||
module.exports = FileError;
|
||||
|
||||
});
|
||||
+300
@@ -0,0 +1,300 @@
|
||||
cordova.define("cordova-plugin-file.FileReader", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var utils = require('cordova/utils');
|
||||
var FileError = require('./FileError');
|
||||
var ProgressEvent = require('./ProgressEvent');
|
||||
var origFileReader = modulemapper.getOriginalSymbol(window, 'FileReader');
|
||||
|
||||
/**
|
||||
* This class reads the mobile device file system.
|
||||
*
|
||||
* For Android:
|
||||
* The root directory is the root of the file system.
|
||||
* To read from the SD card, the file name is "sdcard/my_file.txt"
|
||||
* @constructor
|
||||
*/
|
||||
var FileReader = function () {
|
||||
this._readyState = 0;
|
||||
this._error = null;
|
||||
this._result = null;
|
||||
this._progress = null;
|
||||
this._localURL = '';
|
||||
this._realReader = origFileReader ? new origFileReader() : {}; // eslint-disable-line new-cap
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines the maximum size to read at a time via the native API. The default value is a compromise between
|
||||
* minimizing the overhead of many exec() calls while still reporting progress frequently enough for large files.
|
||||
* (Note attempts to allocate more than a few MB of contiguous memory on the native side are likely to cause
|
||||
* OOM exceptions, while the JS engine seems to have fewer problems managing large strings or ArrayBuffers.)
|
||||
*/
|
||||
FileReader.READ_CHUNK_SIZE = 256 * 1024;
|
||||
|
||||
// States
|
||||
FileReader.EMPTY = 0;
|
||||
FileReader.LOADING = 1;
|
||||
FileReader.DONE = 2;
|
||||
|
||||
utils.defineGetter(FileReader.prototype, 'readyState', function () {
|
||||
return this._localURL ? this._readyState : this._realReader.readyState;
|
||||
});
|
||||
|
||||
utils.defineGetter(FileReader.prototype, 'error', function () {
|
||||
return this._localURL ? this._error : this._realReader.error;
|
||||
});
|
||||
|
||||
utils.defineGetter(FileReader.prototype, 'result', function () {
|
||||
return this._localURL ? this._result : this._realReader.result;
|
||||
});
|
||||
|
||||
function defineEvent (eventName) {
|
||||
utils.defineGetterSetter(FileReader.prototype, eventName, function () {
|
||||
return this._realReader[eventName] || null;
|
||||
}, function (value) {
|
||||
this._realReader[eventName] = value;
|
||||
});
|
||||
}
|
||||
defineEvent('onloadstart'); // When the read starts.
|
||||
defineEvent('onprogress'); // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
|
||||
defineEvent('onload'); // When the read has successfully completed.
|
||||
defineEvent('onerror'); // When the read has failed (see errors).
|
||||
defineEvent('onloadend'); // When the request has completed (either in success or failure).
|
||||
defineEvent('onabort'); // When the read has been aborted. For instance, by invoking the abort() method.
|
||||
|
||||
function initRead (reader, file) {
|
||||
// Already loading something
|
||||
if (reader.readyState === FileReader.LOADING) {
|
||||
throw new FileError(FileError.INVALID_STATE_ERR);
|
||||
}
|
||||
|
||||
reader._result = null;
|
||||
reader._error = null;
|
||||
reader._progress = 0;
|
||||
reader._readyState = FileReader.LOADING;
|
||||
|
||||
if (typeof file.localURL === 'string') {
|
||||
reader._localURL = file.localURL;
|
||||
} else {
|
||||
reader._localURL = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
if (reader.onloadstart) {
|
||||
reader.onloadstart(new ProgressEvent('loadstart', {target: reader}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback used by the following read* functions to handle incremental or final success.
|
||||
* Must be bound to the FileReader's this along with all but the last parameter,
|
||||
* e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset, totalSize, accumulate)
|
||||
* @param readType The name of the read function to call.
|
||||
* @param encoding Text encoding, or null if this is not a text type read.
|
||||
* @param offset Starting offset of the read.
|
||||
* @param totalSize Total number of bytes or chars to read.
|
||||
* @param accumulate A function that takes the callback result and accumulates it in this._result.
|
||||
* @param r Callback result returned by the last read exec() call, or null to begin reading.
|
||||
*/
|
||||
function readSuccessCallback (readType, encoding, offset, totalSize, accumulate, r) {
|
||||
if (this._readyState === FileReader.DONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
var CHUNK_SIZE = FileReader.READ_CHUNK_SIZE;
|
||||
if (readType === 'readAsDataURL') {
|
||||
// Windows proxy does not support reading file slices as Data URLs
|
||||
// so read the whole file at once.
|
||||
CHUNK_SIZE = cordova.platformId === 'windows' ? totalSize : // eslint-disable-line no-undef
|
||||
// Calculate new chunk size for data URLs to be multiply of 3
|
||||
// Otherwise concatenated base64 chunks won't be valid base64 data
|
||||
FileReader.READ_CHUNK_SIZE - (FileReader.READ_CHUNK_SIZE % 3) + 3;
|
||||
}
|
||||
|
||||
if (typeof r !== 'undefined') {
|
||||
accumulate(r);
|
||||
this._progress = Math.min(this._progress + CHUNK_SIZE, totalSize);
|
||||
|
||||
if (typeof this.onprogress === 'function') {
|
||||
this.onprogress(new ProgressEvent('progress', {loaded: this._progress, total: totalSize}));
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof r === 'undefined' || this._progress < totalSize) {
|
||||
var execArgs = [
|
||||
this._localURL,
|
||||
offset + this._progress,
|
||||
offset + this._progress + Math.min(totalSize - this._progress, CHUNK_SIZE)];
|
||||
if (encoding) {
|
||||
execArgs.splice(1, 0, encoding);
|
||||
}
|
||||
exec(
|
||||
readSuccessCallback.bind(this, readType, encoding, offset, totalSize, accumulate),
|
||||
readFailureCallback.bind(this),
|
||||
'File', readType, execArgs);
|
||||
} else {
|
||||
this._readyState = FileReader.DONE;
|
||||
|
||||
if (typeof this.onload === 'function') {
|
||||
this.onload(new ProgressEvent('load', {target: this}));
|
||||
}
|
||||
|
||||
if (typeof this.onloadend === 'function') {
|
||||
this.onloadend(new ProgressEvent('loadend', {target: this}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback used by the following read* functions to handle errors.
|
||||
* Must be bound to the FileReader's this, e.g. readFailureCallback.bind(this)
|
||||
*/
|
||||
function readFailureCallback (e) {
|
||||
if (this._readyState === FileReader.DONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._readyState = FileReader.DONE;
|
||||
this._result = null;
|
||||
this._error = new FileError(e);
|
||||
|
||||
if (typeof this.onerror === 'function') {
|
||||
this.onerror(new ProgressEvent('error', {target: this}));
|
||||
}
|
||||
|
||||
if (typeof this.onloadend === 'function') {
|
||||
this.onloadend(new ProgressEvent('loadend', {target: this}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abort reading file.
|
||||
*/
|
||||
FileReader.prototype.abort = function () {
|
||||
if (origFileReader && !this._localURL) {
|
||||
return this._realReader.abort();
|
||||
}
|
||||
this._result = null;
|
||||
|
||||
if (this._readyState === FileReader.DONE || this._readyState === FileReader.EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._readyState = FileReader.DONE;
|
||||
|
||||
// If abort callback
|
||||
if (typeof this.onabort === 'function') {
|
||||
this.onabort(new ProgressEvent('abort', {target: this}));
|
||||
}
|
||||
// If load end callback
|
||||
if (typeof this.onloadend === 'function') {
|
||||
this.onloadend(new ProgressEvent('loadend', {target: this}));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Read text file.
|
||||
*
|
||||
* @param file {File} File object containing file properties
|
||||
* @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
|
||||
*/
|
||||
FileReader.prototype.readAsText = function (file, encoding) {
|
||||
if (initRead(this, file)) {
|
||||
return this._realReader.readAsText(file, encoding);
|
||||
}
|
||||
|
||||
// Default encoding is UTF-8
|
||||
var enc = encoding || 'UTF-8';
|
||||
|
||||
var totalSize = file.end - file.start;
|
||||
readSuccessCallback.bind(this)('readAsText', enc, file.start, totalSize, function (r) {
|
||||
if (this._progress === 0) {
|
||||
this._result = '';
|
||||
}
|
||||
this._result += r;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Read file and return data as a base64 encoded data url.
|
||||
* A data url is of the form:
|
||||
* data:[<mediatype>][;base64],<data>
|
||||
*
|
||||
* @param file {File} File object containing file properties
|
||||
*/
|
||||
FileReader.prototype.readAsDataURL = function (file) {
|
||||
if (initRead(this, file)) {
|
||||
return this._realReader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
var totalSize = file.end - file.start;
|
||||
readSuccessCallback.bind(this)('readAsDataURL', null, file.start, totalSize, function (r) {
|
||||
var commaIndex = r.indexOf(',');
|
||||
if (this._progress === 0) {
|
||||
this._result = r;
|
||||
} else {
|
||||
this._result += r.substring(commaIndex + 1);
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Read file and return data as a binary data.
|
||||
*
|
||||
* @param file {File} File object containing file properties
|
||||
*/
|
||||
FileReader.prototype.readAsBinaryString = function (file) {
|
||||
if (initRead(this, file)) {
|
||||
return this._realReader.readAsBinaryString(file);
|
||||
}
|
||||
|
||||
var totalSize = file.end - file.start;
|
||||
readSuccessCallback.bind(this)('readAsBinaryString', null, file.start, totalSize, function (r) {
|
||||
if (this._progress === 0) {
|
||||
this._result = '';
|
||||
}
|
||||
this._result += r;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Read file and return data as a binary data.
|
||||
*
|
||||
* @param file {File} File object containing file properties
|
||||
*/
|
||||
FileReader.prototype.readAsArrayBuffer = function (file) {
|
||||
if (initRead(this, file)) {
|
||||
return this._realReader.readAsArrayBuffer(file);
|
||||
}
|
||||
|
||||
var totalSize = file.end - file.start;
|
||||
readSuccessCallback.bind(this)('readAsArrayBuffer', null, file.start, totalSize, function (r) {
|
||||
var resultArray = (this._progress === 0 ? new Uint8Array(totalSize) : new Uint8Array(this._result));
|
||||
resultArray.set(new Uint8Array(r), this._progress);
|
||||
this._result = resultArray.buffer;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
module.exports = FileReader;
|
||||
|
||||
});
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
cordova.define("cordova-plugin-file.FileSystem", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var DirectoryEntry = require('./DirectoryEntry');
|
||||
|
||||
/**
|
||||
* An interface representing a file system
|
||||
*
|
||||
* @constructor
|
||||
* {DOMString} name the unique name of the file system (readonly)
|
||||
* {DirectoryEntry} root directory of the file system (readonly)
|
||||
*/
|
||||
var FileSystem = function (name, root) {
|
||||
this.name = name;
|
||||
if (root) {
|
||||
this.root = new DirectoryEntry(root.name, root.fullPath, this, root.nativeURL);
|
||||
} else {
|
||||
this.root = new DirectoryEntry(this.name, '/', this);
|
||||
}
|
||||
};
|
||||
|
||||
FileSystem.prototype.__format__ = function (fullPath, nativeUrl) {
|
||||
return fullPath;
|
||||
};
|
||||
|
||||
FileSystem.prototype.toJSON = function () {
|
||||
return '<FileSystem: ' + this.name + '>';
|
||||
};
|
||||
|
||||
// Use instead of encodeURI() when encoding just the path part of a URI rather than an entire URI.
|
||||
FileSystem.encodeURIPath = function (path) {
|
||||
// Because # is a valid filename character, it must be encoded to prevent part of the
|
||||
// path from being parsed as a URI fragment.
|
||||
return encodeURI(path).replace(/#/g, '%23');
|
||||
};
|
||||
|
||||
module.exports = FileSystem;
|
||||
|
||||
});
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
cordova.define("cordova-plugin-file.FileUploadOptions", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Options to customize the HTTP request used to upload files.
|
||||
* @constructor
|
||||
* @param fileKey {String} Name of file request parameter.
|
||||
* @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
|
||||
* @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
|
||||
* @param params {Object} Object with key: value params to send to the server.
|
||||
* @param headers {Object} Keys are header names, values are header values. Multiple
|
||||
* headers of the same name are not supported.
|
||||
*/
|
||||
var FileUploadOptions = function (fileKey, fileName, mimeType, params, headers, httpMethod) {
|
||||
this.fileKey = fileKey || null;
|
||||
this.fileName = fileName || null;
|
||||
this.mimeType = mimeType || null;
|
||||
this.params = params || null;
|
||||
this.headers = headers || null;
|
||||
this.httpMethod = httpMethod || null;
|
||||
};
|
||||
|
||||
module.exports = FileUploadOptions;
|
||||
|
||||
});
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
cordova.define("cordova-plugin-file.FileUploadResult", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* FileUploadResult
|
||||
* @constructor
|
||||
*/
|
||||
module.exports = function FileUploadResult (size, code, content) {
|
||||
this.bytesSent = size;
|
||||
this.responseCode = code;
|
||||
this.response = content;
|
||||
};
|
||||
|
||||
});
|
||||
+327
@@ -0,0 +1,327 @@
|
||||
cordova.define("cordova-plugin-file.FileWriter", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
var FileError = require('./FileError');
|
||||
var FileReader = require('./FileReader');
|
||||
var ProgressEvent = require('./ProgressEvent');
|
||||
|
||||
/**
|
||||
* This class writes to the mobile device file system.
|
||||
*
|
||||
* For Android:
|
||||
* The root directory is the root of the file system.
|
||||
* To write to the SD card, the file name is "sdcard/my_file.txt"
|
||||
*
|
||||
* @constructor
|
||||
* @param file {File} File object containing file properties
|
||||
* @param append if true write to the end of the file, otherwise overwrite the file
|
||||
*/
|
||||
var FileWriter = function (file) {
|
||||
this.fileName = '';
|
||||
this.length = 0;
|
||||
if (file) {
|
||||
this.localURL = file.localURL || file;
|
||||
this.length = file.size || 0;
|
||||
}
|
||||
// default is to write at the beginning of the file
|
||||
this.position = 0;
|
||||
|
||||
this.readyState = 0; // EMPTY
|
||||
|
||||
this.result = null;
|
||||
|
||||
// Error
|
||||
this.error = null;
|
||||
|
||||
// Event handlers
|
||||
this.onwritestart = null; // When writing starts
|
||||
this.onprogress = null; // While writing the file, and reporting partial file data
|
||||
this.onwrite = null; // When the write has successfully completed.
|
||||
this.onwriteend = null; // When the request has completed (either in success or failure).
|
||||
this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method.
|
||||
this.onerror = null; // When the write has failed (see errors).
|
||||
};
|
||||
|
||||
// States
|
||||
FileWriter.INIT = 0;
|
||||
FileWriter.WRITING = 1;
|
||||
FileWriter.DONE = 2;
|
||||
|
||||
/**
|
||||
* Abort writing file.
|
||||
*/
|
||||
FileWriter.prototype.abort = function () {
|
||||
// check for invalid state
|
||||
if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
|
||||
throw new FileError(FileError.INVALID_STATE_ERR);
|
||||
}
|
||||
|
||||
// set error
|
||||
this.error = new FileError(FileError.ABORT_ERR);
|
||||
|
||||
this.readyState = FileWriter.DONE;
|
||||
|
||||
// If abort callback
|
||||
if (typeof this.onabort === 'function') {
|
||||
this.onabort(new ProgressEvent('abort', {'target': this}));
|
||||
}
|
||||
|
||||
// If write end callback
|
||||
if (typeof this.onwriteend === 'function') {
|
||||
this.onwriteend(new ProgressEvent('writeend', {'target': this}));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes data to the file
|
||||
*
|
||||
* @param data text or blob to be written
|
||||
* @param isPendingBlobReadResult {Boolean} true if the data is the pending blob read operation result
|
||||
*/
|
||||
FileWriter.prototype.write = function (data, isPendingBlobReadResult) {
|
||||
|
||||
var that = this;
|
||||
var supportsBinary = (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined');
|
||||
/* eslint-disable no-undef */
|
||||
var isProxySupportBlobNatively = (cordova.platformId === 'windows8' || cordova.platformId === 'windows');
|
||||
var isBinary;
|
||||
|
||||
// Check to see if the incoming data is a blob
|
||||
if (data instanceof File || (!isProxySupportBlobNatively && supportsBinary && data instanceof Blob)) {
|
||||
var fileReader = new FileReader();
|
||||
/* eslint-enable no-undef */
|
||||
fileReader.onload = function () {
|
||||
// Call this method again, with the arraybuffer as argument
|
||||
FileWriter.prototype.write.call(that, this.result, true /* isPendingBlobReadResult */);
|
||||
};
|
||||
fileReader.onerror = function () {
|
||||
// DONE state
|
||||
that.readyState = FileWriter.DONE;
|
||||
|
||||
// Save error
|
||||
that.error = this.error;
|
||||
|
||||
// If onerror callback
|
||||
if (typeof that.onerror === 'function') {
|
||||
that.onerror(new ProgressEvent('error', {'target': that}));
|
||||
}
|
||||
|
||||
// If onwriteend callback
|
||||
if (typeof that.onwriteend === 'function') {
|
||||
that.onwriteend(new ProgressEvent('writeend', {'target': that}));
|
||||
}
|
||||
};
|
||||
|
||||
// WRITING state
|
||||
this.readyState = FileWriter.WRITING;
|
||||
|
||||
if (supportsBinary) {
|
||||
fileReader.readAsArrayBuffer(data);
|
||||
} else {
|
||||
fileReader.readAsText(data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Mark data type for safer transport over the binary bridge
|
||||
isBinary = supportsBinary && (data instanceof ArrayBuffer);
|
||||
if (isBinary && cordova.platformId === 'windowsphone') { // eslint-disable-line no-undef
|
||||
// create a plain array, using the keys from the Uint8Array view so that we can serialize it
|
||||
data = Array.apply(null, new Uint8Array(data));
|
||||
}
|
||||
|
||||
// Throw an exception if we are already writing a file
|
||||
if (this.readyState === FileWriter.WRITING && !isPendingBlobReadResult) {
|
||||
throw new FileError(FileError.INVALID_STATE_ERR);
|
||||
}
|
||||
|
||||
// WRITING state
|
||||
this.readyState = FileWriter.WRITING;
|
||||
|
||||
var me = this;
|
||||
|
||||
// If onwritestart callback
|
||||
if (typeof me.onwritestart === 'function') {
|
||||
me.onwritestart(new ProgressEvent('writestart', {'target': me}));
|
||||
}
|
||||
|
||||
// Write file
|
||||
exec(
|
||||
// Success callback
|
||||
function (r) {
|
||||
// If DONE (cancelled), then don't do anything
|
||||
if (me.readyState === FileWriter.DONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// position always increases by bytes written because file would be extended
|
||||
me.position += r;
|
||||
// The length of the file is now where we are done writing.
|
||||
|
||||
me.length = me.position;
|
||||
|
||||
// DONE state
|
||||
me.readyState = FileWriter.DONE;
|
||||
|
||||
// If onwrite callback
|
||||
if (typeof me.onwrite === 'function') {
|
||||
me.onwrite(new ProgressEvent('write', {'target': me}));
|
||||
}
|
||||
|
||||
// If onwriteend callback
|
||||
if (typeof me.onwriteend === 'function') {
|
||||
me.onwriteend(new ProgressEvent('writeend', {'target': me}));
|
||||
}
|
||||
},
|
||||
// Error callback
|
||||
function (e) {
|
||||
// If DONE (cancelled), then don't do anything
|
||||
if (me.readyState === FileWriter.DONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// DONE state
|
||||
me.readyState = FileWriter.DONE;
|
||||
|
||||
// Save error
|
||||
me.error = new FileError(e);
|
||||
|
||||
// If onerror callback
|
||||
if (typeof me.onerror === 'function') {
|
||||
me.onerror(new ProgressEvent('error', {'target': me}));
|
||||
}
|
||||
|
||||
// If onwriteend callback
|
||||
if (typeof me.onwriteend === 'function') {
|
||||
me.onwriteend(new ProgressEvent('writeend', {'target': me}));
|
||||
}
|
||||
}, 'File', 'write', [this.localURL, data, this.position, isBinary]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Moves the file pointer to the location specified.
|
||||
*
|
||||
* If the offset is a negative number the position of the file
|
||||
* pointer is rewound. If the offset is greater than the file
|
||||
* size the position is set to the end of the file.
|
||||
*
|
||||
* @param offset is the location to move the file pointer to.
|
||||
*/
|
||||
FileWriter.prototype.seek = function (offset) {
|
||||
// Throw an exception if we are already writing a file
|
||||
if (this.readyState === FileWriter.WRITING) {
|
||||
throw new FileError(FileError.INVALID_STATE_ERR);
|
||||
}
|
||||
|
||||
if (!offset && offset !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// See back from end of file.
|
||||
if (offset < 0) {
|
||||
this.position = Math.max(offset + this.length, 0);
|
||||
// Offset is bigger than file size so set position
|
||||
// to the end of the file.
|
||||
} else if (offset > this.length) {
|
||||
this.position = this.length;
|
||||
// Offset is between 0 and file size so set the position
|
||||
// to start writing.
|
||||
} else {
|
||||
this.position = offset;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Truncates the file to the size specified.
|
||||
*
|
||||
* @param size to chop the file at.
|
||||
*/
|
||||
FileWriter.prototype.truncate = function (size) {
|
||||
// Throw an exception if we are already writing a file
|
||||
if (this.readyState === FileWriter.WRITING) {
|
||||
throw new FileError(FileError.INVALID_STATE_ERR);
|
||||
}
|
||||
|
||||
// WRITING state
|
||||
this.readyState = FileWriter.WRITING;
|
||||
|
||||
var me = this;
|
||||
|
||||
// If onwritestart callback
|
||||
if (typeof me.onwritestart === 'function') {
|
||||
me.onwritestart(new ProgressEvent('writestart', {'target': this}));
|
||||
}
|
||||
|
||||
// Write file
|
||||
exec(
|
||||
// Success callback
|
||||
function (r) {
|
||||
// If DONE (cancelled), then don't do anything
|
||||
if (me.readyState === FileWriter.DONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// DONE state
|
||||
me.readyState = FileWriter.DONE;
|
||||
|
||||
// Update the length of the file
|
||||
me.length = r;
|
||||
me.position = Math.min(me.position, r);
|
||||
|
||||
// If onwrite callback
|
||||
if (typeof me.onwrite === 'function') {
|
||||
me.onwrite(new ProgressEvent('write', {'target': me}));
|
||||
}
|
||||
|
||||
// If onwriteend callback
|
||||
if (typeof me.onwriteend === 'function') {
|
||||
me.onwriteend(new ProgressEvent('writeend', {'target': me}));
|
||||
}
|
||||
},
|
||||
// Error callback
|
||||
function (e) {
|
||||
// If DONE (cancelled), then don't do anything
|
||||
if (me.readyState === FileWriter.DONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// DONE state
|
||||
me.readyState = FileWriter.DONE;
|
||||
|
||||
// Save error
|
||||
me.error = new FileError(e);
|
||||
|
||||
// If onerror callback
|
||||
if (typeof me.onerror === 'function') {
|
||||
me.onerror(new ProgressEvent('error', {'target': me}));
|
||||
}
|
||||
|
||||
// If onwriteend callback
|
||||
if (typeof me.onwriteend === 'function') {
|
||||
me.onwriteend(new ProgressEvent('writeend', {'target': me}));
|
||||
}
|
||||
}, 'File', 'truncate', [this.localURL, size]);
|
||||
};
|
||||
|
||||
module.exports = FileWriter;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
cordova.define("cordova-plugin-file.Flags", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Supplies arguments to methods that lookup or create files and directories.
|
||||
*
|
||||
* @param create
|
||||
* {boolean} file or directory if it doesn't exist
|
||||
* @param exclusive
|
||||
* {boolean} used with create; if true the command will fail if
|
||||
* target path exists
|
||||
*/
|
||||
function Flags (create, exclusive) {
|
||||
this.create = create || false;
|
||||
this.exclusive = exclusive || false;
|
||||
}
|
||||
|
||||
module.exports = Flags;
|
||||
|
||||
});
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
cordova.define("cordova-plugin-file.LocalFileSystem", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
exports.TEMPORARY = 0;
|
||||
exports.PERSISTENT = 1;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
cordova.define("cordova-plugin-file.Metadata", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Information about the state of the file or directory
|
||||
*
|
||||
* {Date} modificationTime (readonly)
|
||||
*/
|
||||
var Metadata = function (metadata) {
|
||||
if (typeof metadata === 'object') {
|
||||
this.modificationTime = new Date(metadata.modificationTime);
|
||||
this.size = metadata.size || 0;
|
||||
} else if (typeof metadata === 'undefined') {
|
||||
this.modificationTime = null;
|
||||
this.size = 0;
|
||||
} else {
|
||||
/* Backwards compatiblity with platforms that only return a timestamp */
|
||||
this.modificationTime = new Date(metadata);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Metadata;
|
||||
|
||||
});
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
cordova.define("cordova-plugin-file.ProgressEvent", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
|
||||
// Feature test: See if we can instantiate a native ProgressEvent;
|
||||
// if so, use that approach,
|
||||
// otherwise fill-in with our own implementation.
|
||||
//
|
||||
// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.
|
||||
var ProgressEvent = (function () {
|
||||
/*
|
||||
var createEvent = function(data) {
|
||||
var event = document.createEvent('Events');
|
||||
event.initEvent('ProgressEvent', false, false);
|
||||
if (data) {
|
||||
for (var i in data) {
|
||||
if (data.hasOwnProperty(i)) {
|
||||
event[i] = data[i];
|
||||
}
|
||||
}
|
||||
if (data.target) {
|
||||
// TODO: cannot call <some_custom_object>.dispatchEvent
|
||||
// need to first figure out how to implement EventTarget
|
||||
}
|
||||
}
|
||||
return event;
|
||||
};
|
||||
try {
|
||||
var ev = createEvent({type:"abort",target:document});
|
||||
return function ProgressEvent(type, data) {
|
||||
data.type = type;
|
||||
return createEvent(data);
|
||||
};
|
||||
} catch(e){
|
||||
*/
|
||||
return function ProgressEvent (type, dict) {
|
||||
this.type = type;
|
||||
this.bubbles = false;
|
||||
this.cancelBubble = false;
|
||||
this.cancelable = false;
|
||||
this.lengthComputable = false;
|
||||
this.loaded = dict && dict.loaded ? dict.loaded : 0;
|
||||
this.total = dict && dict.total ? dict.total : 0;
|
||||
this.target = dict && dict.target ? dict.target : null;
|
||||
};
|
||||
// }
|
||||
})();
|
||||
|
||||
module.exports = ProgressEvent;
|
||||
|
||||
});
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
cordova.define("cordova-plugin-file.firefoxFileSystem", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* global FILESYSTEM_PREFIX: true, module */
|
||||
|
||||
FILESYSTEM_PREFIX = 'file:///';
|
||||
|
||||
module.exports = {
|
||||
__format__: function (fullPath) {
|
||||
return (FILESYSTEM_PREFIX + this.name + (fullPath[0] === '/' ? '' : '/') + FileSystem.encodeURIPath(fullPath)); // eslint-disable-line no-undef
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
cordova.define("cordova-plugin-file.Preparing", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
(function () {
|
||||
/* global require */
|
||||
|
||||
// Only Chrome uses this file.
|
||||
if (!require('./isChrome')()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var channel = require('cordova/channel');
|
||||
var FileError = require('./FileError');
|
||||
var PERSISTENT_FS_QUOTA = 5 * 1024 * 1024;
|
||||
var filePluginIsReadyEvent = new Event('filePluginIsReady'); // eslint-disable-line no-undef
|
||||
|
||||
var entryFunctionsCreated = false;
|
||||
var quotaWasRequested = false;
|
||||
var eventWasThrown = false;
|
||||
|
||||
if (!window.requestFileSystem) {
|
||||
window.requestFileSystem = function (type, size, win, fail) {
|
||||
if (fail) {
|
||||
fail('Not supported');
|
||||
}
|
||||
};
|
||||
} else {
|
||||
window.requestFileSystem(window.TEMPORARY, 1, createFileEntryFunctions, function () {});
|
||||
}
|
||||
|
||||
if (!window.resolveLocalFileSystemURL) {
|
||||
window.resolveLocalFileSystemURL = function (url, win, fail) {
|
||||
if (fail) {
|
||||
fail('Not supported');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Resolves a filesystem entry by its path - which is passed either in standard (filesystem:file://) or
|
||||
// Cordova-specific (cdvfile://) universal way.
|
||||
// Aligns with specification: http://www.w3.org/TR/2011/WD-file-system-api-20110419/#widl-LocalFileSystem-resolveLocalFileSystemURL
|
||||
var nativeResolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;
|
||||
window.resolveLocalFileSystemURL = function (url, win, fail) {
|
||||
/* If url starts with `cdvfile` then we need convert it to Chrome real url first:
|
||||
cdvfile://localhost/persistent/path/to/file -> filesystem:file://persistent/path/to/file */
|
||||
if (url.trim().substr(0, 7) === 'cdvfile') {
|
||||
/* Quirk:
|
||||
Plugin supports cdvfile://localhost (local resources) only.
|
||||
I.e. external resources are not supported via cdvfile. */
|
||||
if (url.indexOf('cdvfile://localhost') !== -1) {
|
||||
// Browser supports temporary and persistent only
|
||||
var indexPersistent = url.indexOf('persistent');
|
||||
var indexTemporary = url.indexOf('temporary');
|
||||
|
||||
/* Chrome urls start with 'filesystem:' prefix. See quirk:
|
||||
toURL function in Chrome returns filesystem:-prefixed path depending on application host.
|
||||
For example, filesystem:file:///persistent/somefile.txt,
|
||||
filesystem:http://localhost:8080/persistent/somefile.txt. */
|
||||
var prefix = 'filesystem:file:///';
|
||||
if (location.protocol !== 'file:') { // eslint-disable-line no-undef
|
||||
prefix = 'filesystem:' + location.origin + '/'; // eslint-disable-line no-undef
|
||||
}
|
||||
|
||||
var result;
|
||||
if (indexPersistent !== -1) {
|
||||
// cdvfile://localhost/persistent/path/to/file -> filesystem:file://persistent/path/to/file
|
||||
// or filesystem:http://localhost:8080/persistent/path/to/file
|
||||
result = prefix + 'persistent' + url.substr(indexPersistent + 10);
|
||||
nativeResolveLocalFileSystemURL(result, win, fail);
|
||||
return;
|
||||
}
|
||||
|
||||
if (indexTemporary !== -1) {
|
||||
// cdvfile://localhost/temporary/path/to/file -> filesystem:file://temporary/path/to/file
|
||||
// or filesystem:http://localhost:8080/temporary/path/to/file
|
||||
result = prefix + 'temporary' + url.substr(indexTemporary + 9);
|
||||
nativeResolveLocalFileSystemURL(result, win, fail);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// cdvfile other than local file resource is not supported
|
||||
if (fail) {
|
||||
fail(new FileError(FileError.ENCODING_ERR));
|
||||
}
|
||||
} else {
|
||||
nativeResolveLocalFileSystemURL(url, win, fail);
|
||||
}
|
||||
};
|
||||
|
||||
function createFileEntryFunctions (fs) {
|
||||
fs.root.getFile('todelete_658674_833_4_cdv', {create: true}, function (fileEntry) {
|
||||
var fileEntryType = Object.getPrototypeOf(fileEntry);
|
||||
var entryType = Object.getPrototypeOf(fileEntryType);
|
||||
|
||||
// Save the original method
|
||||
var origToURL = entryType.toURL;
|
||||
entryType.toURL = function () {
|
||||
var origURL = origToURL.call(this);
|
||||
if (this.isDirectory && origURL.substr(-1) !== '/') {
|
||||
return origURL + '/';
|
||||
}
|
||||
return origURL;
|
||||
};
|
||||
|
||||
entryType.toNativeURL = function () {
|
||||
console.warn("DEPRECATED: Update your code to use 'toURL'");
|
||||
return this.toURL();
|
||||
};
|
||||
|
||||
entryType.toInternalURL = function () {
|
||||
if (this.toURL().indexOf('persistent') > -1) {
|
||||
return 'cdvfile://localhost/persistent' + this.fullPath;
|
||||
}
|
||||
|
||||
if (this.toURL().indexOf('temporary') > -1) {
|
||||
return 'cdvfile://localhost/temporary' + this.fullPath;
|
||||
}
|
||||
};
|
||||
|
||||
entryType.setMetadata = function (win, fail /*, metadata */) {
|
||||
if (fail) {
|
||||
fail('Not supported');
|
||||
}
|
||||
};
|
||||
|
||||
fileEntry.createWriter(function (writer) {
|
||||
var originalWrite = writer.write;
|
||||
var writerProto = Object.getPrototypeOf(writer);
|
||||
writerProto.write = function (blob) {
|
||||
if (blob instanceof Blob) { // eslint-disable-line no-undef
|
||||
originalWrite.apply(this, [blob]);
|
||||
} else {
|
||||
var realBlob = new Blob([blob]); // eslint-disable-line no-undef
|
||||
originalWrite.apply(this, [realBlob]);
|
||||
}
|
||||
};
|
||||
|
||||
fileEntry.remove(function () { entryFunctionsCreated = true; }, function () { /* empty callback */ });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
window.initPersistentFileSystem = function (size, win, fail) {
|
||||
if (navigator.webkitPersistentStorage) {
|
||||
navigator.webkitPersistentStorage.requestQuota(size, win, fail);
|
||||
return;
|
||||
}
|
||||
|
||||
fail('This browser does not support this function');
|
||||
};
|
||||
|
||||
window.isFilePluginReadyRaised = function () { return eventWasThrown; };
|
||||
|
||||
window.initPersistentFileSystem(PERSISTENT_FS_QUOTA, function () {
|
||||
console.log('Persistent fs quota granted');
|
||||
quotaWasRequested = true;
|
||||
}, function (e) {
|
||||
console.log('Error occured while trying to request Persistent fs quota: ' + JSON.stringify(e));
|
||||
});
|
||||
|
||||
channel.onCordovaReady.subscribe(function () {
|
||||
function dispatchEventIfReady () {
|
||||
if (entryFunctionsCreated && quotaWasRequested) {
|
||||
window.dispatchEvent(filePluginIsReadyEvent);
|
||||
eventWasThrown = true;
|
||||
} else {
|
||||
setTimeout(dispatchEventIfReady, 100);
|
||||
}
|
||||
}
|
||||
|
||||
dispatchEventIfReady();
|
||||
}, false);
|
||||
})();
|
||||
|
||||
});
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
module.exports = function () {
|
||||
// window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and
|
||||
// possibly a good flag to indicate that we're running in Chrome
|
||||
return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;
|
||||
};
|
||||
|
||||
});
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
cordova.define("cordova-plugin-file.fileSystemPaths", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
var channel = require('cordova/channel');
|
||||
|
||||
exports.file = {
|
||||
// Read-only directory where the application is installed.
|
||||
applicationDirectory: null,
|
||||
// Root of app's private writable storage
|
||||
applicationStorageDirectory: null,
|
||||
// Where to put app-specific data files.
|
||||
dataDirectory: null,
|
||||
// Cached files that should survive app restarts.
|
||||
// Apps should not rely on the OS to delete files in here.
|
||||
cacheDirectory: null,
|
||||
// Android: the application space on external storage.
|
||||
externalApplicationStorageDirectory: null,
|
||||
// Android: Where to put app-specific data files on external storage.
|
||||
externalDataDirectory: null,
|
||||
// Android: the application cache on external storage.
|
||||
externalCacheDirectory: null,
|
||||
// Android: the external storage (SD card) root.
|
||||
externalRootDirectory: null,
|
||||
// iOS: Temp directory that the OS can clear at will.
|
||||
tempDirectory: null,
|
||||
// iOS: Holds app-specific files that should be synced (e.g. to iCloud).
|
||||
syncedDataDirectory: null,
|
||||
// iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)
|
||||
documentsDirectory: null,
|
||||
// BlackBerry10: Files globally available to all apps
|
||||
sharedDirectory: null
|
||||
};
|
||||
|
||||
channel.waitForInitialization('onFileSystemPathsReady');
|
||||
channel.onCordovaReady.subscribe(function () {
|
||||
function after (paths) {
|
||||
for (var k in paths) {
|
||||
exports.file[k] = paths[k];
|
||||
}
|
||||
channel.initializationComplete('onFileSystemPathsReady');
|
||||
}
|
||||
exec(after, null, 'File', 'requestAllPaths', []);
|
||||
});
|
||||
|
||||
});
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
cordova.define("cordova-plugin-file.fileSystems", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// Overridden by Android, BlackBerry 10 and iOS to populate fsMap.
|
||||
module.exports.getFs = function (name, callback) {
|
||||
callback(null);
|
||||
};
|
||||
|
||||
});
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
cordova.define("cordova-plugin-file.requestFileSystem", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
(function () {
|
||||
// For browser platform: not all browsers use this file.
|
||||
function checkBrowser () {
|
||||
if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef
|
||||
module.exports = window.requestFileSystem || window.webkitRequestFileSystem;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (checkBrowser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var argscheck = require('cordova/argscheck');
|
||||
var FileError = require('./FileError');
|
||||
var FileSystem = require('./FileSystem');
|
||||
var exec = require('cordova/exec');
|
||||
var fileSystems = require('./fileSystems');
|
||||
|
||||
/**
|
||||
* Request a file system in which to store application data.
|
||||
* @param type local file system type
|
||||
* @param size indicates how much storage space, in bytes, the application expects to need
|
||||
* @param successCallback invoked with a FileSystem object
|
||||
* @param errorCallback invoked if error occurs retrieving file system
|
||||
*/
|
||||
var requestFileSystem = function (type, size, successCallback, errorCallback) {
|
||||
argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
|
||||
var fail = function (code) {
|
||||
if (errorCallback) {
|
||||
errorCallback(new FileError(code));
|
||||
}
|
||||
};
|
||||
|
||||
if (type < 0) {
|
||||
fail(FileError.SYNTAX_ERR);
|
||||
} else {
|
||||
// if successful, return a FileSystem object
|
||||
var success = function (file_system) {
|
||||
if (file_system) {
|
||||
if (successCallback) {
|
||||
fileSystems.getFs(file_system.name, function (fs) {
|
||||
// This should happen only on platforms that haven't implemented requestAllFileSystems (windows)
|
||||
if (!fs) {
|
||||
fs = new FileSystem(file_system.name, file_system.root);
|
||||
}
|
||||
successCallback(fs);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// no FileSystem object returned
|
||||
fail(FileError.NOT_FOUND_ERR);
|
||||
}
|
||||
};
|
||||
exec(success, fail, 'File', 'requestFileSystem', [type, size]);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = requestFileSystem;
|
||||
})();
|
||||
|
||||
});
|
||||
Vendored
+93
@@ -0,0 +1,93 @@
|
||||
cordova.define("cordova-plugin-file.resolveLocalFileSystemURI", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
(function () {
|
||||
// For browser platform: not all browsers use overrided `resolveLocalFileSystemURL`.
|
||||
function checkBrowser () {
|
||||
if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef
|
||||
module.exports.resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (checkBrowser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var argscheck = require('cordova/argscheck');
|
||||
var DirectoryEntry = require('./DirectoryEntry');
|
||||
var FileEntry = require('./FileEntry');
|
||||
var FileError = require('./FileError');
|
||||
var exec = require('cordova/exec');
|
||||
var fileSystems = require('./fileSystems');
|
||||
|
||||
/**
|
||||
* Look up file system Entry referred to by local URI.
|
||||
* @param {DOMString} uri URI referring to a local file or directory
|
||||
* @param successCallback invoked with Entry object corresponding to URI
|
||||
* @param errorCallback invoked if error occurs retrieving file system entry
|
||||
*/
|
||||
module.exports.resolveLocalFileSystemURL = module.exports.resolveLocalFileSystemURL || function (uri, successCallback, errorCallback) {
|
||||
argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);
|
||||
// error callback
|
||||
var fail = function (error) {
|
||||
if (errorCallback) {
|
||||
errorCallback(new FileError(error));
|
||||
}
|
||||
};
|
||||
// sanity check for 'not:valid:filename' or '/not:valid:filename'
|
||||
// file.spec.12 window.resolveLocalFileSystemURI should error (ENCODING_ERR) when resolving invalid URI with leading /.
|
||||
if (!uri || uri.split(':').length > 2) {
|
||||
setTimeout(function () {
|
||||
fail(FileError.ENCODING_ERR);
|
||||
}, 0);
|
||||
return;
|
||||
}
|
||||
// if successful, return either a file or directory entry
|
||||
var success = function (entry) {
|
||||
if (entry) {
|
||||
if (successCallback) {
|
||||
// create appropriate Entry object
|
||||
var fsName = entry.filesystemName || (entry.filesystem && entry.filesystem.name) || (entry.filesystem === window.PERSISTENT ? 'persistent' : 'temporary'); // eslint-disable-line no-undef
|
||||
fileSystems.getFs(fsName, function (fs) {
|
||||
// This should happen only on platforms that haven't implemented requestAllFileSystems (windows)
|
||||
if (!fs) {
|
||||
fs = new FileSystem(fsName, {name: '', fullPath: '/'}); // eslint-disable-line no-undef
|
||||
}
|
||||
var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath, fs, entry.nativeURL) : new FileEntry(entry.name, entry.fullPath, fs, entry.nativeURL);
|
||||
successCallback(result);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// no Entry object returned
|
||||
fail(FileError.NOT_FOUND_ERR);
|
||||
}
|
||||
};
|
||||
|
||||
exec(success, fail, 'File', 'resolveLocalFileSystemURI', [uri]);
|
||||
};
|
||||
|
||||
module.exports.resolveLocalFileSystemURI = function () {
|
||||
console.log('resolveLocalFileSystemURI is deprecated. Please call resolveLocalFileSystemURL instead.');
|
||||
module.exports.resolveLocalFileSystemURL.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
|
||||
});
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
cordova.define("cordova-plugin-fingerprint-aio.Fingerprint", function(require, exports, module) { /*global cordova */
|
||||
|
||||
var Fingerprint = function() {
|
||||
};
|
||||
|
||||
// Plugin Errors
|
||||
Fingerprint.prototype.BIOMETRIC_UNKNOWN_ERROR = -100;
|
||||
Fingerprint.prototype.BIOMETRIC_UNAVAILABLE = -101;
|
||||
Fingerprint.prototype.BIOMETRIC_AUTHENTICATION_FAILED = -102;
|
||||
Fingerprint.prototype.BIOMETRIC_SDK_NOT_SUPPORTED = -103;
|
||||
Fingerprint.prototype.BIOMETRIC_HARDWARE_NOT_SUPPORTED = -104;
|
||||
Fingerprint.prototype.BIOMETRIC_PERMISSION_NOT_GRANTED = -105;
|
||||
Fingerprint.prototype.BIOMETRIC_NOT_ENROLLED = -106;
|
||||
Fingerprint.prototype.BIOMETRIC_INTERNAL_PLUGIN_ERROR = -107;
|
||||
Fingerprint.prototype.BIOMETRIC_DISMISSED = -108;
|
||||
Fingerprint.prototype.BIOMETRIC_PIN_OR_PATTERN_DISMISSED = -109;
|
||||
Fingerprint.prototype.BIOMETRIC_SCREEN_GUARD_UNSECURED = -110;
|
||||
Fingerprint.prototype.BIOMETRIC_LOCKED_OUT = -111;
|
||||
Fingerprint.prototype.BIOMETRIC_LOCKED_OUT_PERMANENT = -112;
|
||||
Fingerprint.prototype.BIOMETRIC_NO_SECRET_FOUND = -113;
|
||||
|
||||
// Biometric types
|
||||
Fingerprint.prototype.BIOMETRIC_TYPE_FINGERPRINT = "finger";
|
||||
Fingerprint.prototype.BIOMETRIC_TYPE_FACE = "face";
|
||||
Fingerprint.prototype.BIOMETRIC_TYPE_COMMON = "biometric";
|
||||
|
||||
Fingerprint.prototype.show = function (params, successCallback, errorCallback) {
|
||||
cordova.exec(
|
||||
successCallback,
|
||||
errorCallback,
|
||||
"Fingerprint",
|
||||
"authenticate",
|
||||
[params]
|
||||
);
|
||||
};
|
||||
|
||||
Fingerprint.prototype.isAvailable = function (successCallback, errorCallback, optionalParams) {
|
||||
cordova.exec(
|
||||
successCallback,
|
||||
errorCallback,
|
||||
"Fingerprint",
|
||||
"isAvailable",
|
||||
[optionalParams]
|
||||
);
|
||||
};
|
||||
|
||||
Fingerprint.prototype.registerBiometricSecret = function (params, successCallback, errorCallback) {
|
||||
cordova.exec(
|
||||
successCallback,
|
||||
errorCallback,
|
||||
"Fingerprint",
|
||||
"registerBiometricSecret",
|
||||
[params]
|
||||
);
|
||||
};
|
||||
|
||||
Fingerprint.prototype.loadBiometricSecret = function (params, successCallback, errorCallback) {
|
||||
cordova.exec(
|
||||
successCallback,
|
||||
errorCallback,
|
||||
"Fingerprint",
|
||||
"loadBiometricSecret",
|
||||
[params]
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = new Fingerprint();
|
||||
|
||||
});
|
||||
+311
@@ -0,0 +1,311 @@
|
||||
cordova.define("cordova-plugin-globalization.GlobalizationProxy", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var GlobalizationError = require('./GlobalizationError');
|
||||
var moment = require('cordova-plugin-globalization.moment');
|
||||
|
||||
function getCrossPlatformLocale () {
|
||||
// userLanguage is for IE, which corresponds to selected regional format
|
||||
return navigator.userLanguage || navigator.language;
|
||||
}
|
||||
|
||||
function stdTimezoneOffset (date) {
|
||||
var jan = new Date(date.getFullYear(), 0, 20);
|
||||
var jul = new Date(date.getFullYear(), 6, 20);
|
||||
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
|
||||
}
|
||||
|
||||
function dst (date) {
|
||||
return date.getTimezoneOffset() < stdTimezoneOffset(date);
|
||||
}
|
||||
|
||||
function dstOffsetAbs (date) {
|
||||
var janOffset = new Date(date.getFullYear(), 0, 20).getTimezoneOffset();
|
||||
var julOffset = new Date(date.getFullYear(), 6, 20).getTimezoneOffset();
|
||||
if (janOffset < 0) { janOffset = -janOffset; }
|
||||
if (julOffset < 0) { julOffset = -julOffset; }
|
||||
var offset = janOffset - julOffset;
|
||||
if (offset < 0) { offset = -offset; }
|
||||
return offset;
|
||||
}
|
||||
|
||||
function getWeekDayNames (locale, options) {
|
||||
var result = [];
|
||||
var date;
|
||||
for (var i = 0; i < 7; i++) {
|
||||
date = new Date(2014, 5, i + 1, 0, 0, 0, 0);
|
||||
result[i] = date.toLocaleDateString(locale, options);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function convertToIntlNumberFormatOptions (options) {
|
||||
switch (options.type) {
|
||||
case 'decimal':
|
||||
return { style: 'decimal' };
|
||||
case 'currency':
|
||||
throw '\'currency\' number type is not supported';
|
||||
case 'percent':
|
||||
return { style: 'percent' };
|
||||
default:
|
||||
throw 'The options.type can be \'decimal\', \'percent\' or \'currency\'';
|
||||
}
|
||||
}
|
||||
|
||||
function convertToMomentLocalizedFormat (options) {
|
||||
var selectorError = 'The options.selector can be \'date\', \'time\' or \'date and time\'';
|
||||
var formatLengthError = 'The options.formatLength can be \'short\', \'medium\', \'long\', or \'full\'';
|
||||
/* eslint-disable no-unreachable */
|
||||
switch (options.formatLength) {
|
||||
case 'short':
|
||||
switch (options.selector) {
|
||||
case 'date and time': return 'lll';
|
||||
case 'date': return 'l';
|
||||
case 'time': return 'LT';
|
||||
default:
|
||||
throw selectorError;
|
||||
}
|
||||
break;
|
||||
case 'medium':
|
||||
switch (options.selector) {
|
||||
case 'date and time': return 'LLL';
|
||||
case 'date': return 'L';
|
||||
case 'time':
|
||||
throw '\'time\' selector does not support \'medium\' formatLength';
|
||||
default:
|
||||
throw selectorError;
|
||||
}
|
||||
break;
|
||||
case 'long':
|
||||
switch (options.selector) {
|
||||
case 'date and time': return 'llll';
|
||||
case 'date': return 'll';
|
||||
case 'time':
|
||||
throw '\'time\' selector does not support \'long\' formatLength';
|
||||
default:
|
||||
throw selectorError;
|
||||
}
|
||||
break;
|
||||
case 'full':
|
||||
switch (options.selector) {
|
||||
case 'date and time': return 'LLLL';
|
||||
case 'date': return 'LL';
|
||||
case 'time': return 'LTS';
|
||||
default:
|
||||
throw selectorError;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw formatLengthError;
|
||||
}
|
||||
}
|
||||
/* eslint-enable no-unreachable */
|
||||
function prepareAndGetDateOptions (options) {
|
||||
options = options || {formatLength: 'short', selector: 'date and time'};
|
||||
options.formatLength = options.formatLength || 'short';
|
||||
options.selector = options.selector || 'date and time';
|
||||
|
||||
return convertToMomentLocalizedFormat(options);
|
||||
}
|
||||
|
||||
var globalization = {
|
||||
getLocaleName: function (win, fail) {
|
||||
try {
|
||||
win({ value: getCrossPlatformLocale() });
|
||||
} catch (e) {
|
||||
fail({ code: 0, message: e.hasOwnProperty('message') ? e.message : e });
|
||||
}
|
||||
},
|
||||
|
||||
numberToString: function (win, fail, args) {
|
||||
try {
|
||||
var options = args[0].options || { type: 'decimal' };
|
||||
options.type = options.type || 'decimal';
|
||||
|
||||
options = convertToIntlNumberFormatOptions(options);
|
||||
|
||||
var formatter = new Intl.NumberFormat(getCrossPlatformLocale(), options);
|
||||
win({ value: formatter.format(args[0].number) });
|
||||
} catch (e) {
|
||||
fail(new GlobalizationError(GlobalizationError.FORMATTING_ERROR,
|
||||
e.hasOwnProperty('message') ? e.message : e));
|
||||
}
|
||||
},
|
||||
|
||||
isDayLightSavingsTime: function (win, fail, args) {
|
||||
try {
|
||||
var date = new Date(args[0].date);
|
||||
win({ dst: dst(date) });
|
||||
} catch (e) {
|
||||
fail({ code: 0, message: e.hasOwnProperty('message') ? e.message : e });
|
||||
}
|
||||
},
|
||||
|
||||
getFirstDayOfWeek: function (win, fail) {
|
||||
try {
|
||||
var locale = getCrossPlatformLocale();
|
||||
moment.locale(locale);
|
||||
// Converting ISO format (Monday = 1, Sunday = 7) to what Cordova expects (Sunday = 1, Monday = 2, Saturday = 7)
|
||||
var shiftDay = moment().weekday(0).isoWeekday() + 1;
|
||||
win({ value: shiftDay % 8 + Math.floor(shiftDay / 8) });
|
||||
} catch (e) {
|
||||
fail({ code: 0, message: e.hasOwnProperty('message') ? e.message : e });
|
||||
}
|
||||
},
|
||||
|
||||
getDateNames: function (win, fail, args) {
|
||||
try {
|
||||
var options = args[0].options || { type: 'wide', item: 'months' };
|
||||
var type = options.type || 'wide';
|
||||
var item = options.item || 'item';
|
||||
|
||||
var locale = getCrossPlatformLocale();
|
||||
|
||||
if (item === 'months' && type === 'wide') {
|
||||
options = { month: 'long' };
|
||||
} else if (item === 'months' && type === 'narrow') {
|
||||
options = { month: 'short' };
|
||||
} else if (item === 'days' && type === 'wide') {
|
||||
options = { weekday: 'long' };
|
||||
} else if (item === 'days' && type === 'narrow') {
|
||||
options = { weekday: 'short' };
|
||||
} else {
|
||||
throw 'Incorrect type or item';
|
||||
}
|
||||
|
||||
var result = [];
|
||||
if (item === 'months') {
|
||||
for (var i = 0; i < 12; i++) {
|
||||
var date = new Date(2014, i, 20, 0, 0, 0, 0);
|
||||
result[i] = date.toLocaleDateString(locale, options);
|
||||
}
|
||||
} else {
|
||||
result = getWeekDayNames(locale, options);
|
||||
}
|
||||
|
||||
win({ value: result });
|
||||
} catch (e) {
|
||||
fail({ code: 0, message: e.hasOwnProperty('message') ? e.message : e });
|
||||
}
|
||||
},
|
||||
|
||||
getDatePattern: function (win, fail) {
|
||||
try {
|
||||
var formatter = new Intl.DateTimeFormat(getCrossPlatformLocale());
|
||||
var timezone = formatter.hasOwnProperty('resolved') ? formatter.resolved.timeZone : '';
|
||||
var dstOffset = dstOffsetAbs(new Date());
|
||||
|
||||
win({
|
||||
utc_offset: new Date().getTimezoneOffset() * (-60),
|
||||
dst_offset: dstOffset * 60,
|
||||
timezone: timezone,
|
||||
pattern: ''
|
||||
});
|
||||
} catch (e) {
|
||||
fail(new GlobalizationError(GlobalizationError.PATTERN_ERROR,
|
||||
e.hasOwnProperty('message') ? e.message : e));
|
||||
}
|
||||
},
|
||||
|
||||
getNumberPattern: function (win, fail, args) {
|
||||
try {
|
||||
var options = args[0].options || { type: 'decimal' };
|
||||
options.type = options.type || 'decimal';
|
||||
|
||||
options = convertToIntlNumberFormatOptions(options);
|
||||
|
||||
var formatter = new Intl.NumberFormat(getCrossPlatformLocale(), options);
|
||||
|
||||
if (!formatter.hasOwnProperty('resolved')) {
|
||||
fail('Not supported');
|
||||
return;
|
||||
}
|
||||
var pattern = formatter.resolved.pattern;
|
||||
win({
|
||||
pattern: pattern,
|
||||
symbol: '',
|
||||
fraction: 0,
|
||||
rounding: 0,
|
||||
positive: '',
|
||||
negative: '',
|
||||
decimal: '',
|
||||
grouping: ''
|
||||
});
|
||||
} catch (e) {
|
||||
fail(new GlobalizationError(GlobalizationError.PATTERN_ERROR,
|
||||
e.hasOwnProperty('message') ? e.message : e));
|
||||
}
|
||||
},
|
||||
|
||||
getPreferredLanguage: function (win, fail, args) {
|
||||
// Falling back on locale
|
||||
globalization.getLocaleName(win, fail);
|
||||
},
|
||||
|
||||
getCurrencyPattern: function (win, fail, args) {
|
||||
fail('Not supported');
|
||||
},
|
||||
|
||||
stringToDate: function (win, fail, args) {
|
||||
try {
|
||||
var options = prepareAndGetDateOptions(args[0].options);
|
||||
moment.locale(getCrossPlatformLocale());
|
||||
|
||||
var date = moment(args[0].dateString, options).toDate();
|
||||
|
||||
win({
|
||||
year: date.getFullYear(),
|
||||
month: date.getMonth(),
|
||||
day: date.getDate(),
|
||||
hour: date.getHours(),
|
||||
minute: date.getMinutes(),
|
||||
second: date.getSeconds(),
|
||||
millisecond: date.getMilliseconds()
|
||||
});
|
||||
} catch (e) {
|
||||
fail(new GlobalizationError(GlobalizationError.PARSING_ERROR,
|
||||
e.hasOwnProperty('message') ? e.message : e));
|
||||
}
|
||||
},
|
||||
|
||||
stringToNumber: function (win, fail, args) {
|
||||
fail('Not supported');
|
||||
},
|
||||
|
||||
dateToString: function (win, fail, args) {
|
||||
try {
|
||||
var date = new Date(args[0].date);
|
||||
var options = prepareAndGetDateOptions(args[0].options);
|
||||
moment.locale(getCrossPlatformLocale());
|
||||
|
||||
win({ value: moment(date).format(options) });
|
||||
} catch (e) {
|
||||
fail(new GlobalizationError(GlobalizationError.FORMATTING_ERROR,
|
||||
e.hasOwnProperty('message') ? e.message : e));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = globalization;
|
||||
|
||||
require('cordova/exec/proxy').add('Globalization', module.exports);
|
||||
|
||||
});
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
cordova.define("cordova-plugin-globalization.GlobalizationError", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Globalization error object
|
||||
*
|
||||
* @constructor
|
||||
* @param code
|
||||
* @param message
|
||||
*/
|
||||
var GlobalizationError = function (code, message) {
|
||||
this.code = code || null;
|
||||
this.message = message || '';
|
||||
};
|
||||
|
||||
// Globalization error codes
|
||||
GlobalizationError.UNKNOWN_ERROR = 0;
|
||||
GlobalizationError.FORMATTING_ERROR = 1;
|
||||
GlobalizationError.PARSING_ERROR = 2;
|
||||
GlobalizationError.PATTERN_ERROR = 3;
|
||||
|
||||
module.exports = GlobalizationError;
|
||||
|
||||
});
|
||||
+4537
File diff suppressed because it is too large
Load Diff
+387
@@ -0,0 +1,387 @@
|
||||
cordova.define("cordova-plugin-globalization.globalization", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck');
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
var globalization = {
|
||||
|
||||
/**
|
||||
* Returns the string identifier for the client's current language.
|
||||
* It returns the language identifier string to the successCB callback with a
|
||||
* properties object as a parameter. If there is an error getting the language,
|
||||
* then the errorCB callback is invoked.
|
||||
*
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
*
|
||||
* @return Object.value {String}: The language identifier
|
||||
*
|
||||
* @error GlobalizationError.UNKNOWN_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.getPreferredLanguage(function (language) {alert('language:' + language.value + '\n');},
|
||||
* function () {});
|
||||
*/
|
||||
getPreferredLanguage: function (successCB, failureCB) {
|
||||
argscheck.checkArgs('fF', 'Globalization.getPreferredLanguage', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'getPreferredLanguage', []);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the string identifier for the client's current locale setting.
|
||||
* It returns the locale identifier string to the successCB callback with a
|
||||
* properties object as a parameter. If there is an error getting the locale,
|
||||
* then the errorCB callback is invoked.
|
||||
*
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
*
|
||||
* @return Object.value {String}: The locale identifier
|
||||
*
|
||||
* @error GlobalizationError.UNKNOWN_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.getLocaleName(function (locale) {alert('locale:' + locale.value + '\n');},
|
||||
* function () {});
|
||||
*/
|
||||
getLocaleName: function (successCB, failureCB) {
|
||||
argscheck.checkArgs('fF', 'Globalization.getLocaleName', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'getLocaleName', []);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a date formatted as a string according to the client's user preferences and
|
||||
* calendar using the time zone of the client. It returns the formatted date string to the
|
||||
* successCB callback with a properties object as a parameter. If there is an error
|
||||
* formatting the date, then the errorCB callback is invoked.
|
||||
*
|
||||
* The defaults are: formatLenght="short" and selector="date and time"
|
||||
*
|
||||
* @param {Date} date
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
* @param {Object} options {optional}
|
||||
* formatLength {String}: 'short', 'medium', 'long', or 'full'
|
||||
* selector {String}: 'date', 'time', or 'date and time'
|
||||
*
|
||||
* @return Object.value {String}: The localized date string
|
||||
*
|
||||
* @error GlobalizationError.FORMATTING_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.dateToString(new Date(),
|
||||
* function (date) {alert('date:' + date.value + '\n');},
|
||||
* function (errorCode) {alert(errorCode);},
|
||||
* {formatLength:'short'});
|
||||
*/
|
||||
dateToString: function (date, successCB, failureCB, options) {
|
||||
argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
|
||||
var dateValue = date.valueOf();
|
||||
exec(successCB, failureCB, 'Globalization', 'dateToString', [{'date': dateValue, 'options': options}]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses a date formatted as a string according to the client's user
|
||||
* preferences and calendar using the time zone of the client and returns
|
||||
* the corresponding date object. It returns the date to the successCB
|
||||
* callback with a properties object as a parameter. If there is an error
|
||||
* parsing the date string, then the errorCB callback is invoked.
|
||||
*
|
||||
* The defaults are: formatLength="short" and selector="date and time"
|
||||
*
|
||||
* @param {String} dateString
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
* @param {Object} options {optional}
|
||||
* formatLength {String}: 'short', 'medium', 'long', or 'full'
|
||||
* selector {String}: 'date', 'time', or 'date and time'
|
||||
*
|
||||
* @return Object.year {Number}: The four digit year
|
||||
* Object.month {Number}: The month from (0 - 11)
|
||||
* Object.day {Number}: The day from (1 - 31)
|
||||
* Object.hour {Number}: The hour from (0 - 23)
|
||||
* Object.minute {Number}: The minute from (0 - 59)
|
||||
* Object.second {Number}: The second from (0 - 59)
|
||||
* Object.millisecond {Number}: The milliseconds (from 0 - 999),
|
||||
* not available on all platforms
|
||||
*
|
||||
* @error GlobalizationError.PARSING_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.stringToDate('4/11/2011',
|
||||
* function (date) { alert('Month:' + date.month + '\n' +
|
||||
* 'Day:' + date.day + '\n' +
|
||||
* 'Year:' + date.year + '\n');},
|
||||
* function (errorCode) {alert(errorCode);},
|
||||
* {selector:'date'});
|
||||
*/
|
||||
stringToDate: function (dateString, successCB, failureCB, options) {
|
||||
argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'stringToDate', [{'dateString': dateString, 'options': options}]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a pattern string for formatting and parsing dates according to the client's
|
||||
* user preferences. It returns the pattern to the successCB callback with a
|
||||
* properties object as a parameter. If there is an error obtaining the pattern,
|
||||
* then the errorCB callback is invoked.
|
||||
*
|
||||
* The defaults are: formatLength="short" and selector="date and time"
|
||||
*
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
* @param {Object} options {optional}
|
||||
* formatLength {String}: 'short', 'medium', 'long', or 'full'
|
||||
* selector {String}: 'date', 'time', or 'date and time'
|
||||
*
|
||||
* @return Object.pattern {String}: The date and time pattern for formatting and parsing dates.
|
||||
* The patterns follow Unicode Technical Standard #35
|
||||
* http://unicode.org/reports/tr35/tr35-4.html
|
||||
* Object.timezone {String}: The abbreviated name of the time zone on the client
|
||||
* Object.utc_offset {Number}: The current difference in seconds between the client's
|
||||
* time zone and coordinated universal time.
|
||||
* Object.dst_offset {Number}: The current daylight saving time offset in seconds
|
||||
* between the client's non-daylight saving's time zone
|
||||
* and the client's daylight saving's time zone.
|
||||
*
|
||||
* @error GlobalizationError.PATTERN_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.getDatePattern(
|
||||
* function (date) {alert('pattern:' + date.pattern + '\n');},
|
||||
* function () {},
|
||||
* {formatLength:'short'});
|
||||
*/
|
||||
getDatePattern: function (successCB, failureCB, options) {
|
||||
argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'getDatePattern', [{'options': options}]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array of either the names of the months or days of the week
|
||||
* according to the client's user preferences and calendar. It returns the array of names to the
|
||||
* successCB callback with a properties object as a parameter. If there is an error obtaining the
|
||||
* names, then the errorCB callback is invoked.
|
||||
*
|
||||
* The defaults are: type="wide" and item="months"
|
||||
*
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
* @param {Object} options {optional}
|
||||
* type {String}: 'narrow' or 'wide'
|
||||
* item {String}: 'months', or 'days'
|
||||
*
|
||||
* @return Object.value {Array{String}}: The array of names starting from either
|
||||
* the first month in the year or the
|
||||
* first day of the week.
|
||||
* @error GlobalizationError.UNKNOWN_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.getDateNames(function (names) {
|
||||
* for(var i = 0; i < names.value.length; i++) {
|
||||
* alert('Month:' + names.value[i] + '\n');}},
|
||||
* function () {});
|
||||
*/
|
||||
getDateNames: function (successCB, failureCB, options) {
|
||||
argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'getDateNames', [{'options': options}]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns whether daylight savings time is in effect for a given date using the client's
|
||||
* time zone and calendar. It returns whether or not daylight savings time is in effect
|
||||
* to the successCB callback with a properties object as a parameter. If there is an error
|
||||
* reading the date, then the errorCB callback is invoked.
|
||||
*
|
||||
* @param {Date} date
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
*
|
||||
* @return Object.dst {Boolean}: The value "true" indicates that daylight savings time is
|
||||
* in effect for the given date and "false" indicate that it is not.
|
||||
*
|
||||
* @error GlobalizationError.UNKNOWN_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.isDayLightSavingsTime(new Date(),
|
||||
* function (date) {alert('dst:' + date.dst + '\n');}
|
||||
* function () {});
|
||||
*/
|
||||
isDayLightSavingsTime: function (date, successCB, failureCB) {
|
||||
argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', arguments);
|
||||
var dateValue = date.valueOf();
|
||||
exec(successCB, failureCB, 'Globalization', 'isDayLightSavingsTime', [{'date': dateValue}]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the first day of the week according to the client's user preferences and calendar.
|
||||
* The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
|
||||
* It returns the day to the successCB callback with a properties object as a parameter.
|
||||
* If there is an error obtaining the pattern, then the errorCB callback is invoked.
|
||||
*
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
*
|
||||
* @return Object.value {Number}: The number of the first day of the week.
|
||||
*
|
||||
* @error GlobalizationError.UNKNOWN_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.getFirstDayOfWeek(function (day)
|
||||
* { alert('Day:' + day.value + '\n');},
|
||||
* function () {});
|
||||
*/
|
||||
getFirstDayOfWeek: function (successCB, failureCB) {
|
||||
argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'getFirstDayOfWeek', []);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a number formatted as a string according to the client's user preferences.
|
||||
* It returns the formatted number string to the successCB callback with a properties object as a
|
||||
* parameter. If there is an error formatting the number, then the errorCB callback is invoked.
|
||||
*
|
||||
* The defaults are: type="decimal"
|
||||
*
|
||||
* @param {Number} number
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
* @param {Object} options {optional}
|
||||
* type {String}: 'decimal', "percent", or 'currency'
|
||||
*
|
||||
* @return Object.value {String}: The formatted number string.
|
||||
*
|
||||
* @error GlobalizationError.FORMATTING_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.numberToString(3.25,
|
||||
* function (number) {alert('number:' + number.value + '\n');},
|
||||
* function () {},
|
||||
* {type:'decimal'});
|
||||
*/
|
||||
numberToString: function (number, successCB, failureCB, options) {
|
||||
argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'numberToString', [{'number': number, 'options': options}]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses a number formatted as a string according to the client's user preferences and
|
||||
* returns the corresponding number. It returns the number to the successCB callback with a
|
||||
* properties object as a parameter. If there is an error parsing the number string, then
|
||||
* the errorCB callback is invoked.
|
||||
*
|
||||
* The defaults are: type="decimal"
|
||||
*
|
||||
* @param {String} numberString
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
* @param {Object} options {optional}
|
||||
* type {String}: 'decimal', "percent", or 'currency'
|
||||
*
|
||||
* @return Object.value {Number}: The parsed number.
|
||||
*
|
||||
* @error GlobalizationError.PARSING_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.stringToNumber('1234.56',
|
||||
* function (number) {alert('Number:' + number.value + '\n');},
|
||||
* function () { alert('Error parsing number');});
|
||||
*/
|
||||
stringToNumber: function (numberString, successCB, failureCB, options) {
|
||||
argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'stringToNumber', [{'numberString': numberString, 'options': options}]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a pattern string for formatting and parsing numbers according to the client's user
|
||||
* preferences. It returns the pattern to the successCB callback with a properties object as a
|
||||
* parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
|
||||
*
|
||||
* The defaults are: type="decimal"
|
||||
*
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
* @param {Object} options {optional}
|
||||
* type {String}: 'decimal', "percent", or 'currency'
|
||||
*
|
||||
* @return Object.pattern {String}: The number pattern for formatting and parsing numbers.
|
||||
* The patterns follow Unicode Technical Standard #35.
|
||||
* http://unicode.org/reports/tr35/tr35-4.html
|
||||
* Object.symbol {String}: The symbol to be used when formatting and parsing
|
||||
* e.g., percent or currency symbol.
|
||||
* Object.fraction {Number}: The number of fractional digits to use when parsing and
|
||||
* formatting numbers.
|
||||
* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
|
||||
* Object.positive {String}: The symbol to use for positive numbers when parsing and formatting.
|
||||
* Object.negative: {String}: The symbol to use for negative numbers when parsing and formatting.
|
||||
* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
|
||||
* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
|
||||
*
|
||||
* @error GlobalizationError.PATTERN_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.getNumberPattern(
|
||||
* function (pattern) {alert('Pattern:' + pattern.pattern + '\n');},
|
||||
* function () {});
|
||||
*/
|
||||
getNumberPattern: function (successCB, failureCB, options) {
|
||||
argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'getNumberPattern', [{'options': options}]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a pattern string for formatting and parsing currency values according to the client's
|
||||
* user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
|
||||
* properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
|
||||
* callback is invoked.
|
||||
*
|
||||
* @param {String} currencyCode
|
||||
* @param {Function} successCB
|
||||
* @param {Function} errorCB
|
||||
*
|
||||
* @return Object.pattern {String}: The currency pattern for formatting and parsing currency values.
|
||||
* The patterns follow Unicode Technical Standard #35
|
||||
* http://unicode.org/reports/tr35/tr35-4.html
|
||||
* Object.code {String}: The ISO 4217 currency code for the pattern.
|
||||
* Object.fraction {Number}: The number of fractional digits to use when parsing and
|
||||
* formatting currency.
|
||||
* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
|
||||
* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
|
||||
* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
|
||||
*
|
||||
* @error GlobalizationError.FORMATTING_ERROR
|
||||
*
|
||||
* Example
|
||||
* globalization.getCurrencyPattern('EUR',
|
||||
* function (currency) {alert('Pattern:' + currency.pattern + '\n');}
|
||||
* function () {});
|
||||
*/
|
||||
getCurrencyPattern: function (currencyCode, successCB, failureCB) {
|
||||
argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
|
||||
exec(successCB, failureCB, 'Globalization', 'getCurrencyPattern', [{'currencyCode': currencyCode}]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = globalization;
|
||||
|
||||
});
|
||||
_platforms/browser/platform_www/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js
Vendored
+247
@@ -0,0 +1,247 @@
|
||||
cordova.define("cordova-plugin-inappbrowser.InAppBrowserProxy", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
var browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton;
|
||||
|
||||
function attachNavigationEvents (element, callback) {
|
||||
var onError = function () {
|
||||
try {
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
};
|
||||
|
||||
element.addEventListener('pageshow', function () {
|
||||
try {
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener('load', function () {
|
||||
try {
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener('error', onError);
|
||||
element.addEventListener('abort', onError);
|
||||
}
|
||||
|
||||
var IAB = {
|
||||
close: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
// use the "open" function callback so that the exit event is fired properly
|
||||
if (IAB._win) IAB._win({ type: 'exit' });
|
||||
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
browserWrap = null;
|
||||
popup = null;
|
||||
}
|
||||
},
|
||||
|
||||
show: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = 'block';
|
||||
}
|
||||
},
|
||||
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0];
|
||||
var target = args[1];
|
||||
var features = args[2];
|
||||
|
||||
IAB._win = win;
|
||||
|
||||
if (target === '_self' || !target) {
|
||||
window.location = strUrl;
|
||||
} else if (target === '_system') {
|
||||
modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, '_blank');
|
||||
} else {
|
||||
// "_blank" or anything else
|
||||
if (!browserWrap) {
|
||||
browserWrap = document.createElement('div');
|
||||
browserWrap.style.position = 'absolute';
|
||||
browserWrap.style.top = '0';
|
||||
browserWrap.style.left = '0';
|
||||
browserWrap.style.boxSizing = 'border-box';
|
||||
browserWrap.style.borderWidth = '40px';
|
||||
browserWrap.style.width = '100vw';
|
||||
browserWrap.style.height = '100vh';
|
||||
browserWrap.style.borderStyle = 'solid';
|
||||
browserWrap.style.borderColor = 'rgba(0,0,0,0.25)';
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
IAB.close();
|
||||
}, 0);
|
||||
};
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
}
|
||||
|
||||
if (features.indexOf('hidden=yes') !== -1) {
|
||||
browserWrap.style.display = 'none';
|
||||
}
|
||||
|
||||
popup = document.createElement('iframe');
|
||||
popup.style.borderWidth = '0px';
|
||||
popup.style.width = '100%';
|
||||
|
||||
browserWrap.appendChild(popup);
|
||||
|
||||
if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) {
|
||||
popup.style.height = 'calc(100% - 60px)';
|
||||
popup.style.marginBottom = '-4px';
|
||||
|
||||
navigationButtonsDiv = document.createElement('div');
|
||||
navigationButtonsDiv.style.height = '60px';
|
||||
navigationButtonsDiv.style.backgroundColor = '#404040';
|
||||
navigationButtonsDiv.style.zIndex = '999';
|
||||
navigationButtonsDiv.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
navigationButtonsDivInner = document.createElement('div');
|
||||
navigationButtonsDivInner.style.paddingTop = '10px';
|
||||
navigationButtonsDivInner.style.height = '50px';
|
||||
navigationButtonsDivInner.style.width = '160px';
|
||||
navigationButtonsDivInner.style.margin = '0 auto';
|
||||
navigationButtonsDivInner.style.backgroundColor = '#404040';
|
||||
navigationButtonsDivInner.style.zIndex = '999';
|
||||
navigationButtonsDivInner.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
backButton = document.createElement('button');
|
||||
backButton.style.width = '40px';
|
||||
backButton.style.height = '40px';
|
||||
backButton.style.borderRadius = '40px';
|
||||
|
||||
backButton.innerHTML = '←';
|
||||
backButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoBack) {
|
||||
popup.goBack();
|
||||
}
|
||||
});
|
||||
|
||||
forwardButton = document.createElement('button');
|
||||
forwardButton.style.marginLeft = '20px';
|
||||
forwardButton.style.width = '40px';
|
||||
forwardButton.style.height = '40px';
|
||||
forwardButton.style.borderRadius = '40px';
|
||||
|
||||
forwardButton.innerHTML = '→';
|
||||
forwardButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoForward) {
|
||||
popup.goForward();
|
||||
}
|
||||
});
|
||||
|
||||
closeButton = document.createElement('button');
|
||||
closeButton.style.marginLeft = '20px';
|
||||
closeButton.style.width = '40px';
|
||||
closeButton.style.height = '40px';
|
||||
closeButton.style.borderRadius = '40px';
|
||||
|
||||
closeButton.innerHTML = '✖';
|
||||
closeButton.addEventListener('click', function (e) {
|
||||
setTimeout(function () {
|
||||
IAB.close();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// iframe navigation is not yet supported
|
||||
backButton.disabled = true;
|
||||
forwardButton.disabled = true;
|
||||
|
||||
navigationButtonsDivInner.appendChild(backButton);
|
||||
navigationButtonsDivInner.appendChild(forwardButton);
|
||||
navigationButtonsDivInner.appendChild(closeButton);
|
||||
navigationButtonsDiv.appendChild(navigationButtonsDivInner);
|
||||
|
||||
browserWrap.appendChild(navigationButtonsDiv);
|
||||
} else {
|
||||
popup.style.height = '100%';
|
||||
}
|
||||
|
||||
// start listening for navigation events
|
||||
attachNavigationEvents(popup, win);
|
||||
|
||||
popup.src = strUrl;
|
||||
}
|
||||
},
|
||||
|
||||
injectScriptCode: function (win, fail, args) {
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (browserWrap && popup) {
|
||||
try {
|
||||
popup.contentWindow.eval(code);
|
||||
if (hasCallback) {
|
||||
win([]);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
injectScriptFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
},
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
||||
console.warn(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
},
|
||||
|
||||
injectStyleFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = IAB;
|
||||
|
||||
require('cordova/exec/proxy').add('InAppBrowser', module.exports);
|
||||
|
||||
});
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
cordova.define("cordova-plugin-inappbrowser.inappbrowser", function(require, exports, module) { /*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*
|
||||
*/
|
||||
|
||||
(function () {
|
||||
var exec = require('cordova/exec');
|
||||
var channel = require('cordova/channel');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
|
||||
function InAppBrowser () {
|
||||
this.channels = {
|
||||
beforeload: channel.create('beforeload'),
|
||||
loadstart: channel.create('loadstart'),
|
||||
loadstop: channel.create('loadstop'),
|
||||
loaderror: channel.create('loaderror'),
|
||||
exit: channel.create('exit'),
|
||||
customscheme: channel.create('customscheme'),
|
||||
message: channel.create('message')
|
||||
};
|
||||
}
|
||||
|
||||
InAppBrowser.prototype = {
|
||||
_eventHandler: function (event) {
|
||||
if (event && event.type in this.channels) {
|
||||
if (event.type === 'beforeload') {
|
||||
this.channels[event.type].fire(event, this._loadAfterBeforeload);
|
||||
} else {
|
||||
this.channels[event.type].fire(event);
|
||||
}
|
||||
}
|
||||
},
|
||||
_loadAfterBeforeload: function (strUrl) {
|
||||
strUrl = urlutil.makeAbsolute(strUrl);
|
||||
exec(null, null, 'InAppBrowser', 'loadAfterBeforeload', [strUrl]);
|
||||
},
|
||||
close: function (eventname) {
|
||||
exec(null, null, 'InAppBrowser', 'close', []);
|
||||
},
|
||||
show: function (eventname) {
|
||||
exec(null, null, 'InAppBrowser', 'show', []);
|
||||
},
|
||||
hide: function (eventname) {
|
||||
exec(null, null, 'InAppBrowser', 'hide', []);
|
||||
},
|
||||
addEventListener: function (eventname, f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].subscribe(f);
|
||||
}
|
||||
},
|
||||
removeEventListener: function (eventname, f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].unsubscribe(f);
|
||||
}
|
||||
},
|
||||
|
||||
executeScript: function (injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, 'InAppBrowser', 'injectScriptCode', [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
exec(cb, null, 'InAppBrowser', 'injectScriptFile', [injectDetails.file, !!cb]);
|
||||
} else {
|
||||
throw new Error('executeScript requires exactly one of code or file to be specified');
|
||||
}
|
||||
},
|
||||
|
||||
insertCSS: function (injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, 'InAppBrowser', 'injectStyleCode', [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
exec(cb, null, 'InAppBrowser', 'injectStyleFile', [injectDetails.file, !!cb]);
|
||||
} else {
|
||||
throw new Error('insertCSS requires exactly one of code or file to be specified');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function (strUrl, strWindowName, strWindowFeatures, callbacks) {
|
||||
// Don't catch calls that write to existing frames (e.g. named iframes).
|
||||
if (window.frames && window.frames[strWindowName]) {
|
||||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
|
||||
return origOpenFunc.apply(window, arguments);
|
||||
}
|
||||
|
||||
strUrl = urlutil.makeAbsolute(strUrl);
|
||||
var iab = new InAppBrowser();
|
||||
|
||||
callbacks = callbacks || {};
|
||||
for (var callbackName in callbacks) {
|
||||
iab.addEventListener(callbackName, callbacks[callbackName]);
|
||||
}
|
||||
|
||||
var cb = function (eventname) {
|
||||
iab._eventHandler(eventname);
|
||||
};
|
||||
|
||||
strWindowFeatures = strWindowFeatures || '';
|
||||
|
||||
exec(cb, cb, 'InAppBrowser', 'open', [strUrl, strWindowName, strWindowFeatures]);
|
||||
return iab;
|
||||
};
|
||||
})();
|
||||
|
||||
});
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
cordova.define("cordova-plugin-ionic-webview.IonicWebView", function(require, exports, module) { var exec = require('cordova/exec');
|
||||
|
||||
var WebView = {
|
||||
convertFileSrc: function(url) {
|
||||
if (!url) {
|
||||
return url;
|
||||
}
|
||||
if (url.indexOf('/')===0) {
|
||||
return window.WEBVIEW_SERVER_URL + '/_app_file_' + url;
|
||||
}
|
||||
if (url.indexOf('file://')===0) {
|
||||
return window.WEBVIEW_SERVER_URL + url.replace('file://', '/_app_file_');
|
||||
}
|
||||
if (url.indexOf('content://')===0) {
|
||||
return window.WEBVIEW_SERVER_URL + url.replace('content:/', '/_app_content_');
|
||||
}
|
||||
return url;
|
||||
},
|
||||
setServerBasePath: function(path) {
|
||||
exec(null, null, 'IonicWebView', 'setServerBasePath', [path]);
|
||||
},
|
||||
getServerBasePath: function(callback) {
|
||||
exec(callback, null, 'IonicWebView', 'getServerBasePath', []);
|
||||
},
|
||||
persistServerBasePath: function() {
|
||||
exec(null, null, 'IonicWebView', 'persistServerBasePath', []);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = WebView;
|
||||
|
||||
});
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
cordova.define("cordova-plugin-mfp.mfp", function(require, exports, module) { /*
|
||||
Licensed Materials - Property of IBM
|
||||
|
||||
(C) Copyright 2015 IBM Corp.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
var mfpreadyfired = false;
|
||||
|
||||
// {platform}/www/plugins/cordova-plugin-mfp/worklight
|
||||
var WORKLIGHT_DIR = 'plugins/cordova-plugin-mfp/worklight';
|
||||
|
||||
// {platform}/www/plugins/cordova-plugin-mfp/worklight/static_app_props.js
|
||||
var STATIC_APP_PROPS_PATH = WORKLIGHT_DIR + '/static_app_props.js';
|
||||
|
||||
// {platform}/www/plugins/cordova-plugin-mfp//worklight/wljq.js
|
||||
var WLJQ_PATH = WORKLIGHT_DIR + '/wljq.js';
|
||||
|
||||
// {platform}/www/plugins/cordova-plugin-mfp//worklight/ibmmfpf.js
|
||||
var WORKLIGHT_PATH = WORKLIGHT_DIR + '/ibmmfpf.js';
|
||||
|
||||
// {platform}/www/plugins/cordova-plugin-mfp/worklight/analytics/ibmmfpfanalytics.js
|
||||
var ANALYTICS_PATH = WORKLIGHT_DIR + '/analytics/ibmmfpfanalytics.js';
|
||||
|
||||
document.addEventListener('deviceready', loadMFP, false);
|
||||
|
||||
function loadMFP(){
|
||||
if(typeof WL !== 'undefined' && WL.StaticAppProps){
|
||||
//console.log('Developer is injecting scripts manually');
|
||||
/*
|
||||
<script src="worklight/static_app_props.js"></script>
|
||||
<script src="cordova.js"></script>
|
||||
<script src="worklight/wljq.js"></script>
|
||||
<script src="worklight/worklight.js"></script>
|
||||
<script src="worklight/checksum.js"></script>
|
||||
*/
|
||||
mfpready();
|
||||
} else {
|
||||
//console.log('Inject MFP Scripts dynamically');
|
||||
loadJQ();
|
||||
}
|
||||
|
||||
function loadJQ(){
|
||||
//console.log("injecting script wljq.js");
|
||||
injectScript(findCordovaPath() + WLJQ_PATH, loadAnalytics,bootError);
|
||||
}
|
||||
|
||||
function loadAnalytics(){
|
||||
//console.log("worklight/analytics/ibmmfpfanalytics.js");
|
||||
injectScript(findCordovaPath() + ANALYTICS_PATH, loadWorklight,bootError);
|
||||
}
|
||||
|
||||
function loadWorklight(){
|
||||
//console.log("injecting script worklight.js");
|
||||
injectScript(findCordovaPath() + WORKLIGHT_PATH, loadStaticAppProps,bootError);
|
||||
}
|
||||
|
||||
function loadStaticAppProps(){
|
||||
//console.log("worklight/static_app_props.js");
|
||||
injectScript(findCordovaPath() + STATIC_APP_PROPS_PATH, mfpready,bootError);
|
||||
}
|
||||
|
||||
function mfpready (){
|
||||
//call WL.Client.init unless user defined mfpClientCustomInit = true in config.xml, and propagated to static_app_props.js
|
||||
if(WL.StaticAppProps && !WL.StaticAppProps.mfpClientCustomInit){
|
||||
console.log('Calling WL.Client.init(wlInitOptions);')
|
||||
var options = typeof wlInitOptions !== 'undefined' ? wlInitOptions : {};
|
||||
try{
|
||||
WL.Client.init(options).then(
|
||||
() => {
|
||||
mfpFire();
|
||||
}
|
||||
);
|
||||
} catch (e) {//init function returns promise only if user did not implement wlCommonInit(); otherwise we need to catch the calling function.
|
||||
if (e instanceof TypeError) {
|
||||
mfpFire();// calling mfpFire() for normal MFP framework initialization.
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('Developer will call WL.Client.init manually');
|
||||
mfpFire();
|
||||
}
|
||||
//Inform developer they should load their own jquery and not use MFP internal version
|
||||
deprecateWLJQ();
|
||||
}
|
||||
|
||||
function mfpFire(){
|
||||
//console.log("bootstrap.js dispatching mfpjsloaded event");
|
||||
try {
|
||||
var wlevent = new Event('mfpjsloaded');
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof TypeError) {
|
||||
// Trying to use old events
|
||||
wlevent = document.createEvent('Event');
|
||||
wlevent.initEvent('mfpjsloaded', true, true);
|
||||
}
|
||||
else {
|
||||
console.error(e.message);
|
||||
}
|
||||
}
|
||||
// Dispatch the event.
|
||||
document.dispatchEvent(wlevent);
|
||||
mfpreadyfired = true;
|
||||
}
|
||||
|
||||
function deprecateWLJQ(){
|
||||
setTimeout(function checkWLJQ(){
|
||||
if(window.$ === WLJQ){
|
||||
console.error('Using WLJQ as your window.$ is deprecated, if needed, please load your own JQuery instance');
|
||||
} else if(window.jQuery === WLJQ){
|
||||
console.error('Using WLJQ as your window.jQuery is deprecated, if needed, please load your own JQuery instance');
|
||||
}
|
||||
},10000);
|
||||
}
|
||||
|
||||
function injectScript(url, onload, onerror) {
|
||||
var script = document.createElement("script");
|
||||
// onload fires even when script fails loads with an error.
|
||||
script.onload = onload;
|
||||
// onerror fires for malformed URLs.
|
||||
script.onerror = onerror;
|
||||
script.src = url;
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
function bootError(){
|
||||
console.error("mfp bootstrap failed to inject script");
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(function mfpTimeOut(){
|
||||
if(!mfpreadyfired){
|
||||
loadMFP();
|
||||
}
|
||||
},6000);
|
||||
|
||||
|
||||
function findCordovaPath() {
|
||||
var path = null;
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
var startterm = '/cordova.';
|
||||
var term = '/cordova.js';
|
||||
for (var n = scripts.length-1; n>-1; n--) {
|
||||
var src = scripts[n].src.replace(/\?.*$/, ''); // Strip any query param (CB-6007).
|
||||
// APAR 119091: findCordovaPath function to work with hashed builds.
|
||||
var idx = src.indexOf(startterm);
|
||||
if (idx >= 0 && src.substring(idx).replace(/cordova\.[^\.\/]*\.js/, "cordova.js") == term) {
|
||||
term = src.substring(idx);
|
||||
}
|
||||
if (src.indexOf(term) === (src.length - term.length)) {
|
||||
path = src.substring(0, src.length - term.length) + '/';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
});
|
||||
Vendored
+1696
File diff suppressed because it is too large
Load Diff
+8950
File diff suppressed because one or more lines are too long
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "PII user facing" ,
|
||||
"accessDenied" : "Zugriff verweigert",
|
||||
"authFailure" : "Beim Verarbeiten der Anforderung von der Anwendung wurde ein Fehler festgestellt.",
|
||||
"applicationDenied" : "Anwendung inaktiviert",
|
||||
"browserIsNotSupported" : "{0} wird momentan nicht unterstützt.",
|
||||
"cancel" : "Abbrechen",
|
||||
"close" : "Schließen",
|
||||
"cookiesAreDisabled" : "In Ihrem Browser sind Cookies inaktiviert. Aktivieren Sie Cookies, damit die Anwendung ordnungsgemäß funktioniert.",
|
||||
"copyToClipboard" : "Kopieren",
|
||||
"details" : "Details",
|
||||
"diagApp" : "App-Diagnose",
|
||||
"diagTime" : "Zeit",
|
||||
"diagApplicationName" : "Anwendungsname",
|
||||
"diagApplicationVersion" : "Anwendungsversion",
|
||||
"diagServiceURL" : "Service-URL",
|
||||
"diagDevicePlatform" : "Geräteplattform",
|
||||
"diagDeviceVersion" : "Geräteversion",
|
||||
"diagScreenResolution" : "Bildschirmauflösung",
|
||||
"diagAirplaneMode" : "Flugzeugmodus",
|
||||
"diagUsingNetwork" : "Verwendetes Netz",
|
||||
"diagWifiName" : "WiFi-Name",
|
||||
"diagMobileNetworkType" : "Typ des mobilen Netzes",
|
||||
"diagCarrierName" : "Name des Betreibers",
|
||||
"diagErrorCode" : "Fehlercode",
|
||||
"diagErrorMessage" : "Fehlernachricht",
|
||||
"diagHttpStatus" : "HTTP-Status",
|
||||
"diagIPAddress" : "IP-Adresse",
|
||||
"directUpdateNotificationTitle" : "Aktualisierung verfügbar",
|
||||
"directUpdateNotificationMessage" : "Es stehen neuere Webressourcen zur Verfügung. Für Aktualisierung bestätigen (Dateigröße: {0} MB).",
|
||||
"directUpdateNotificationMessageKilobytes" : "Es stehen neuere Webressourcen zur Verfügung. Für Aktualisierung bestätigen (Dateigröße: {0} KB).",
|
||||
"directUpdateErrorTitle" : "Aktualisierung fehlgeschlagen",
|
||||
"directUpdateErrorMessage" : "Die direkte Aktualisierung ist fehlgeschlagen.",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "Für die Anwendung steht ein Update zur Verfügung, aber es ist nicht genügend Speicherplatz auf den Gerät vorhanden (erforderlicher Speicherplatz: {0} MB, verfügbarer Speicherplatz: {1} MB).",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "Die Datei mit der Anwendungsaktualisierung konnte nicht heruntergeladen werden.",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "Die Datei mit der Anwendungsaktualisierung konnte nicht verarbeitet werden.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "Die App-Ressourcen können nicht heruntergeladen werden. Geben Sie in der Anzeige mit den Einstellungen die App-ID an.",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "Die Anwendung '{0}' wurde nicht gefunden. Implementieren Sie sie zunächst im Server der Plattform IBM MobileFirst.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "Die App-Ressourcen können nicht heruntergeladen werden. Geben Sie in der Anzeige mit den Einstellungen die App-Version an.",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "Die App-Ressourcen können nicht heruntergeladen werden. Die Oberfläche {0} ist nicht vorhanden. Stellen Sie sicher, dass getSkinName() eine gültige Oberfläche ergibt.",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "Anwendung '{0}' {1} für {2} nicht gefunden",
|
||||
"deviceAuthenticationFail" : "Konnektivitätsfehler",
|
||||
"saveCertificateFailure" : "Das Zertifikat kann nicht gespeichert werden.",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "Es ist keine Verbindung zum Server verfügbar. Die Anwendungsressourcen können nicht heruntergeladen werden.",
|
||||
"expandWindow" : "Anwendung zur Benutzung einblenden",
|
||||
"exit" : "Beenden",
|
||||
"exitApplication" : "Anwendung beenden",
|
||||
"error" : "Fehler",
|
||||
"gadgetUpdateAvailable" : "Anwendungsaktualisierung verfügbar",
|
||||
"getNewVersion" : "Neue Version abrufen",
|
||||
"handleTimeOut" : "Zeitlimitüberschreitung bei der Anforderung für {0}. Stellen Sie sicher, dass die Hostadresse für die Anwendung verfügbar ist (besonders für Android- und iPhone-Apps).",
|
||||
"invalidUsernamePassword" : "Ungültiger Benutzername oder ungültiges Kennwort",
|
||||
"keepAliveInBackgroundText" : "Anwendung wird im Hintergrund weiter ausgeführt",
|
||||
"loading" : "Ladevorgang",
|
||||
"login" : "Anmeldung",
|
||||
"minimize" : "Symbolgröße",
|
||||
"missingFeatureException" : "{1} konnte nicht aufgerufen werden, weil {0} in der Anwendung fehlt. Fügen Sie {0} zum Anwendungsdeskriptor hinzu. Erstellen und implementieren Sie dann die Anwendung neu.",
|
||||
"name" : "Name:",
|
||||
"noInternet" : "Keine Verbindung zum Service verfügbar",
|
||||
"notificationTitle" : "Servicebenachrichtigung",
|
||||
"notAvailable" : "Nicht verfügbar",
|
||||
"ok" : "OK",
|
||||
"password" : "Kennwort:",
|
||||
"reload" : "Erneut laden",
|
||||
"restore" : "Wiederherstellen",
|
||||
"requestTimeout" : "Die Anwendung konnte keine Verbindung zu dem Service herstellen.",
|
||||
"responseNotRecognized" : "Nicht erwartete Antwort",
|
||||
"settings" : "Einstellungen",
|
||||
"serverError" : "Fehler beim Prozeduraufruf",
|
||||
"tryAgain" : "Erneut versuchen",
|
||||
"userInstanceAccessViolationException" : "Sie versuchen, sich bei einer nicht für Sie registrierten Anwendung anzumelden.",
|
||||
"unexpectedError" : "Der Server konnte die Anfrage von der Anwendung nicht verarbeiten. Versuchen Sie es später erneut.",
|
||||
"unresponsiveHost" : "Der Service ist zurzeit nicht verfügbar.",
|
||||
"update" : "Aktualisieren",
|
||||
"upgrade" : "Upgrade",
|
||||
"upgradeGadget" : "Die Version Ihrer Anwendung ist {0}. Version {1} dieser Anwendung ist verfügbar. Klicken Sie zum Herunterladen und Installieren auf OK.",
|
||||
"wlclientInitFailure" : "Fehler",
|
||||
"wlSettings" : "Einstellungen der Plattform IBM MobileFirst",
|
||||
"userEnrollmentUnsupportedOS" : "Fehler bei der Authentifizierung des Benutzerzertifikats. Nicht unterstützte Clientplattform.",
|
||||
"failureCallingMethod" : "Fehler beim Aufrufen von {0}",
|
||||
"challengeHandlingCanceled" : "Die Abfrage-Handler-Operation wurde abgebrochen.",
|
||||
"unsupportedEnvironment" : "Nicht unterstützte Umgebung",
|
||||
"redirect" : "Umleiten"
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "Para el usuario de PII" ,
|
||||
"accessDenied" : "Acceso denegado",
|
||||
"authFailure" : "Se ha producido un error al procesar la solicitud desde la aplicación.",
|
||||
"applicationDenied" : "Aplicación inhabilitada",
|
||||
"browserIsNotSupported" : "{0} no está actualmente soportado.",
|
||||
"cancel" : "Cancelar",
|
||||
"close" : "Cerrar",
|
||||
"cookiesAreDisabled" : "Las cookies están actualmente inhabilitadas en el navegador. Debe habilitarlas para que la aplicación funcione correctamente.",
|
||||
"copyToClipboard" : "Copiar",
|
||||
"details" : "Detalles",
|
||||
"diagApp" : "Diagnóstico de aplicación",
|
||||
"diagTime" : "Hora",
|
||||
"diagApplicationName" : "Nombre de aplicación",
|
||||
"diagApplicationVersion" : "Versión de aplicación",
|
||||
"diagServiceURL" : "URL de servicio",
|
||||
"diagDevicePlatform" : "Plataforma de dispositivo",
|
||||
"diagDeviceVersion" : "Versión de dispositivo",
|
||||
"diagScreenResolution" : "Resolución de pantalla",
|
||||
"diagAirplaneMode" : "Modo avión",
|
||||
"diagUsingNetwork" : "Uso de red",
|
||||
"diagWifiName" : "Nombre de WiFi",
|
||||
"diagMobileNetworkType" : "Tipo de red móvil",
|
||||
"diagCarrierName" : "Nombre de operadora",
|
||||
"diagErrorCode" : "Código de error",
|
||||
"diagErrorMessage" : "Mensaje de error",
|
||||
"diagHttpStatus" : "Estado HTTP",
|
||||
"diagIPAddress" : "Dirección IP",
|
||||
"directUpdateNotificationTitle" : "Actualización disponible",
|
||||
"directUpdateNotificationMessage" : "Hay disponibles nuevos recursos web. Confirme para actualizar. (tamaño archivos: {0} MB).",
|
||||
"directUpdateNotificationMessageKilobytes" : "Hay disponibles nuevos recursos web. Confirme para actualizar. (tamaño archivos: {0} KB).",
|
||||
"directUpdateErrorTitle" : "Actualización fallida",
|
||||
"directUpdateErrorMessage" : "Anomalía en Direct Update. ",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "Hay una actualización disponible para la aplicación, pero no hay suficiente espacio disponible en el dispositivo (espacio necesario: {0} MB, espacio disponible: {1} MB).",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "Ha fallado la descarga del archivo de actualización de aplicación.",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "Ha fallado el proceso del archivo de actualización de la aplicación.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "No se pueden descargar los recursos de la aplicación. Especifique la ID de la aplicación en la pantalla Configuración.",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "La aplicación '{0}' no se puede encontrar. Despliéguela en primer lugar en IBM MobileFirst Platform Server.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "No se pueden descargar los recursos de la aplicación. Especifique la Versión de la aplicación en la pantalla Configuración.",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "No se pueden descargar los recursos de la aplicación. El skin: {0} no existe. Asegúrese de que getSkinName() se resuelve en un skin válido.",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "No se puede encontrar la aplicación '{0}' {1} para {2}",
|
||||
"deviceAuthenticationFail" : "Error de conectividad",
|
||||
"saveCertificateFailure" : "No se ha podido guardar el certificado",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "No está disponible una conexión al servidor. No se pueden descargar los recursos de la aplicación.",
|
||||
"expandWindow" : "Expanda la aplicación para utilizarla",
|
||||
"exit" : "Salir",
|
||||
"exitApplication" : "Salir de la aplicación",
|
||||
"error" : "Error",
|
||||
"gadgetUpdateAvailable" : "Actualización de la aplicación disponible",
|
||||
"getNewVersion" : "Obtener una versión nueva",
|
||||
"handleTimeOut" : "Se ha excedido el tiempo de espera de la solicitud de {0}. Asegúrese de que la dirección del host está disponible en la aplicación (especialmente relevante para aplicaciones Android e iPhone).",
|
||||
"invalidUsernamePassword" : "Nombre de usuario o contraseña no válido",
|
||||
"keepAliveInBackgroundText" : "La aplicación continúa en ejecución en segundo plano",
|
||||
"loading" : "Cargando",
|
||||
"login" : "Iniciar sesión",
|
||||
"minimize" : "Minimizar",
|
||||
"missingFeatureException" : "No se ha podido llamar a {1} porque falta {0} en la aplicación. Añada {0} al descriptor de la aplicación, vuelva a crearlo y despliéguelo.",
|
||||
"name" : "Nombre:",
|
||||
"noInternet" : "La conexión al servicio no está disponible.",
|
||||
"notificationTitle" : "Notificación de servicio",
|
||||
"notAvailable" : "No disponible",
|
||||
"ok" : "Aceptar",
|
||||
"password" : "Contraseña:",
|
||||
"reload" : "Volver a cargar",
|
||||
"restore" : "Restaurar",
|
||||
"requestTimeout" : "La aplicación no se ha podido conectar al servicio.",
|
||||
"responseNotRecognized" : "Respuesta inesperada.",
|
||||
"settings" : "Valores",
|
||||
"serverError" : "Error de invocación de procedimiento.",
|
||||
"tryAgain" : "Inténtelo de nuevo",
|
||||
"userInstanceAccessViolationException" : "Está intentando iniciar sesión en una aplicación que no está registrada para el usuario.",
|
||||
"unexpectedError" : "El servidor no ha podido procesar la solicitud desde la aplicación. Inténtelo de nuevo más tarde.",
|
||||
"unresponsiveHost" : "El servicio no está disponible en este momento.",
|
||||
"update" : "Actualizar",
|
||||
"upgrade" : "Actualizar",
|
||||
"upgradeGadget" : "La versión de la aplicación es {0}. La versión {1} de esta aplicación está disponible. Pulse Aceptar para descargarla e instalarla.",
|
||||
"wlclientInitFailure" : "Error",
|
||||
"wlSettings" : "Configuración de IBM MobileFirst Platform",
|
||||
"userEnrollmentUnsupportedOS" : "Error de autenticación de certificado de usuario: plataforma de cliente no soportada.",
|
||||
"failureCallingMethod" : "Error de llamada {0}",
|
||||
"challengeHandlingCanceled" : "Se ha cancelado la operación del manejador de desafíos.",
|
||||
"unsupportedEnvironment" : "Entorno no soportado",
|
||||
"redirect" : "Redireccionar"
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "PII user facing" ,
|
||||
"accessDenied" : "Accès refusé",
|
||||
"authFailure" : "Une erreur est survenue lors du traitement de la demande de l'application.",
|
||||
"applicationDenied" : "Application désactivée",
|
||||
"browserIsNotSupported" : "{0} n'est pas pris en charge actuellement.",
|
||||
"cancel" : "Annuler",
|
||||
"close" : "Fermer",
|
||||
"cookiesAreDisabled" : "Les cookies sont désactivés dans votre navigateur. Vous devez les activer pour que l'application fonctionne correctement.",
|
||||
"copyToClipboard" : "Copier",
|
||||
"details" : "Détails",
|
||||
"diagApp" : "Diagnostics d'application",
|
||||
"diagTime" : "Heure",
|
||||
"diagApplicationName" : "Nom de l'application",
|
||||
"diagApplicationVersion" : "Version de l'application",
|
||||
"diagServiceURL" : "Adresse URL du service",
|
||||
"diagDevicePlatform" : "Plateforme du terminal",
|
||||
"diagDeviceVersion" : "Version du terminal",
|
||||
"diagScreenResolution" : "Résolution d'écran",
|
||||
"diagAirplaneMode" : "Mode avion",
|
||||
"diagUsingNetwork" : "Utilisation du réseau",
|
||||
"diagWifiName" : "Nom du Wi-Fi",
|
||||
"diagMobileNetworkType" : "Type de réseau de mobile",
|
||||
"diagCarrierName" : "Nom de l'opérateur",
|
||||
"diagErrorCode" : "Code d'erreur",
|
||||
"diagErrorMessage" : "Message d'erreur",
|
||||
"diagHttpStatus" : "Statut HTTP",
|
||||
"diagIPAddress" : "Adresse IP",
|
||||
"directUpdateNotificationTitle" : "Mise à jour disponible",
|
||||
"directUpdateNotificationMessage" : "Des ressources Web plus récentes sont disponibles. Confirmez la mise à jour. (taille du fichier : {0} Mo).",
|
||||
"directUpdateNotificationMessageKilobytes" : "Des ressources Web plus récentes sont disponibles. Confirmez la mise à jour. (taille du fichier : {0} Ko).",
|
||||
"directUpdateErrorTitle" : "Echec de la mise à jour",
|
||||
"directUpdateErrorMessage" : "Echec de la mise à jour directe.",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "Une mise à jour de l'application est disponible mais l'espace disponible sur le terminal est insuffisant (taille requise : {0} Mo, espace disponible : {1} Mo).",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "Echec du téléchargement du fichier de mise à jour de l'application.",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "Echec du traitement du fichier de mise à jour de l'application.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "Impossible de télécharger les ressources de l'application. Spécifiez l'ID de l'application dans l'écran Paramètres.",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "L'application '{0}' est introuvable. Déployez-la d'abord sur le serveur IBM MobileFirst Platform.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "Impossible de télécharger les ressources de l'application. Spécifiez la version de l'application dans l'écran Paramètres.",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "Impossible de télécharger les ressources de l'application. L'habillage {0} n'existe pas. Assurez-vous que getSkinName() génère un habillage valide.",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "Application '{0}' {1} introuvable pour {2}",
|
||||
"deviceAuthenticationFail" : "Erreur de connectivité",
|
||||
"saveCertificateFailure" : "Impossible de sauvegarder le certificat",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "La connexion au serveur n'est pas disponible. Impossible de télécharger les ressources d'application.",
|
||||
"expandWindow" : "Développez l'application pour l'utiliser",
|
||||
"exit" : "Quitter",
|
||||
"exitApplication" : "Quitter l'application",
|
||||
"error" : "Erreur",
|
||||
"gadgetUpdateAvailable" : "Mise à jour de l'application disponible",
|
||||
"getNewVersion" : "Obtenir la nouvelle version",
|
||||
"handleTimeOut" : "La demande a expiré pour {0}. Assurez-vous que l'adresse de l'hôte est disponible dans l'application (notamment pour les applications Android et iPhone).",
|
||||
"invalidUsernamePassword" : "Nom d'utilisateur ou mot de passe non valide",
|
||||
"keepAliveInBackgroundText" : "L'application continue de s'exécuter en arrière-plan",
|
||||
"loading" : "Chargement",
|
||||
"login" : "Connexion",
|
||||
"minimize" : "Réduire",
|
||||
"missingFeatureException" : "Echec de l'appel de {1} car {0} manque dans l'application. Ajoutez {0} au descripteur d'application, régénérez-le et déployez-le.",
|
||||
"name" : "Nom\u00A0:",
|
||||
"noInternet" : "La connexion au service n'est pas disponible.",
|
||||
"notificationTitle" : "Notification de service",
|
||||
"notAvailable" : "Non disponible",
|
||||
"ok" : "OK",
|
||||
"password" : "Mot de passe\u00A0:",
|
||||
"reload" : "Recharger",
|
||||
"restore" : "Restaurer",
|
||||
"requestTimeout" : "L'application n'est pas parvenue à se connecter au service.",
|
||||
"responseNotRecognized" : "Réponse inattendue.",
|
||||
"settings" : "Paramètres",
|
||||
"serverError" : "Erreur d'invocation de procédure.",
|
||||
"tryAgain" : "Réessayer",
|
||||
"userInstanceAccessViolationException" : "Vous essayez de vous connecter à une application qui n'est pas enregistrée pour vous.",
|
||||
"unexpectedError" : "Le serveur n'est pas parvenu à traiter la demande de l'application. Essayez à nouveau ultérieurement.",
|
||||
"unresponsiveHost" : "Le service n'est pas disponible actuellement.",
|
||||
"update" : "Mettre à jour",
|
||||
"upgrade" : "Mettre à niveau",
|
||||
"upgradeGadget" : "La version de votre application est {0}. La version {1} de cette application est disponible. Cliquez sur OK pour la télécharger et l'installer.",
|
||||
"wlclientInitFailure" : "Erreur",
|
||||
"wlSettings" : "Paramètres d'IBM MobileFirst Platform",
|
||||
"userEnrollmentUnsupportedOS" : "Echec de l'authentification du certificat utilisateur\u00A0: plateforme client non prise en charge.",
|
||||
"failureCallingMethod" : "Echec de l'appel de {0}",
|
||||
"challengeHandlingCanceled" : "L'opération du gestionnaire de demandes d'authentification a été annulée.",
|
||||
"unsupportedEnvironment" : "Environnement non pris en charge",
|
||||
"redirect" : "Redirection"
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "PII user facing" ,
|
||||
"accessDenied" : "הגישה חסומה",
|
||||
"authFailure" : "אירעה שגיאה בעיבוד הבקשה מהיישום.",
|
||||
"applicationDenied" : "היישום מושבת",
|
||||
"browserIsNotSupported" : "{0} אינו נתמך כרגע.",
|
||||
"cancel" : "ביטול",
|
||||
"close" : "סגירה",
|
||||
"cookiesAreDisabled" : "קובצי Cookie מושבתית כרגע בדפדפן שלכם. עליכם להפעיל אותם כדי שהיישום יפעל כהלכה.",
|
||||
"copyToClipboard" : "העתקה",
|
||||
"details" : "פרטים",
|
||||
"diagApp" : "אבחון יישום",
|
||||
"diagTime" : "שעה",
|
||||
"diagApplicationName" : "שם יישום",
|
||||
"diagApplicationVersion" : "גרסת יישום",
|
||||
"diagServiceURL" : "URL שירות",
|
||||
"diagDevicePlatform" : "פלטפורמת התקן",
|
||||
"diagDeviceVersion" : "גרסת התקן",
|
||||
"diagScreenResolution" : "רזולוציית מסך",
|
||||
"diagAirplaneMode" : "מצב מטוס",
|
||||
"diagUsingNetwork" : "שימוש ברשת",
|
||||
"diagWifiName" : "שם WiFi",
|
||||
"diagMobileNetworkType" : "סוג רשת ניידת",
|
||||
"diagCarrierName" : "שם ספק",
|
||||
"diagErrorCode" : "קוד שגיאה",
|
||||
"diagErrorMessage" : "הודעת שגיאה",
|
||||
"diagHttpStatus" : "מצב HTTP",
|
||||
"diagIPAddress" : "כתובת IP",
|
||||
"directUpdateNotificationTitle" : "יש עדכון זמין",
|
||||
"directUpdateNotificationMessage" : "זמינים משאבי רשת חדשים יותר. אשרו כדי לעדכן. (גודל הקובץ הוא {0} MB).",
|
||||
"directUpdateNotificationMessageKilobytes" : "זמינים משאבי רשת חדשים יותר. אשרו כדי לעדכן. (גודל הקובץ הוא {0} KB).",
|
||||
"directUpdateErrorTitle" : "העדכון נכשל",
|
||||
"directUpdateErrorMessage" : "כשל בעדכון הישיר.",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "זמין עדכון עבור היישום, אך אין מספיק מקום זמין בהתקן (גודל דרוש: {0} MB, שטח זמין: {1} MB).",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "כשל בהורדת קובץ העדכון של היישום.",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "כשל בעיבוד קובץ העדכון של היישום.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "לא ניתן להוריד את משאבי היישום. ציינו את זיהוי היישום במסך ההגדרות.",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "היישום '{0}' לא נמצא . הציבו אותו תחילה בשרת IBM MobileFirst Platform.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "לא ניתן להוריד את משאבי היישום. ציינו את גרסת היישום במסך ההגדרות.",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "לא ניתן להוריד את משאבי היישום. המעטפת: {0} אינה קיימת. ודאי כי הפונקציה getSkinName() מתפענחת למעטפת חוקית.",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "היישום '{0}' {1} עבור {2} לא נמצא",
|
||||
"deviceAuthenticationFail" : "שגיאת קישוריות",
|
||||
"saveCertificateFailure" : "לא ניתן לשמור את האישור",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "חיבור לשרת אינו זמין. לא ניתן להוריד את משאבי היישום.",
|
||||
"expandWindow" : "הרחיבו את היישום כדי להשתמש בו",
|
||||
"exit" : "יציאה",
|
||||
"exitApplication" : "יציאה מהיישום",
|
||||
"error" : "שגיאה",
|
||||
"gadgetUpdateAvailable" : "זמין עדכון של היישום",
|
||||
"getNewVersion" : "קבלת גרסה חדשה",
|
||||
"handleTimeOut" : "הבקשה חרגה ממגבלת הזמן עבור {0}. ודאו שכתובת המארח זמינה ליישום (רלוונטי בעיקר עבור יישומי Android ו-iPhone).",
|
||||
"invalidUsernamePassword" : "שם משתמש או סיסמה לא חוקיים",
|
||||
"keepAliveInBackgroundText" : "היישום ממשיך לרוץ ברקע",
|
||||
"loading" : "טעינה",
|
||||
"login" : "התחברות",
|
||||
"minimize" : "מזעור",
|
||||
"missingFeatureException" : "Failed to call {1} because {0} is missing in the application. Add {0} to the application descriptor, rebuild and deploy it.",
|
||||
"name" : "שם:",
|
||||
"noInternet" : "אין חיבור זמין לשירות זה.",
|
||||
"notificationTitle" : "הודעת שירות",
|
||||
"notAvailable" : "לא זמין",
|
||||
"ok" : "אישור",
|
||||
"password" : "סיסמה:",
|
||||
"reload" : "טעינה מחדש",
|
||||
"restore" : "שחזור",
|
||||
"requestTimeout" : "היישום לא הצליח להתחבר לשירות.",
|
||||
"responseNotRecognized" : "תגובה לא צפויה.",
|
||||
"settings" : "הגדרות",
|
||||
"serverError" : "שגיאה בהפעלת פרוצדורה.",
|
||||
"tryAgain" : "נסיון חוזר",
|
||||
"userInstanceAccessViolationException" : "אתם מנסים להתחבר ליישום שאינו רשום עבורכם.",
|
||||
"unexpectedError" : "השרת לא הצליח לעבד את הבקשה מהיישום. נא לנסות שוב מאוחר יותר.",
|
||||
"unresponsiveHost" : "השירות אינו זמין כרגע.",
|
||||
"update" : "עדכון",
|
||||
"upgrade" : "שידרוג",
|
||||
"upgradeGadget" : "גרסת היישום שלכם היא {0}. גרסה {1} של יישום זה זמינה כעת. לחצו על 'אישור' כדי להוריד ולהתקין אותה.",
|
||||
"wlclientInitFailure" : "שגיאה",
|
||||
"wlSettings" : "הגדרות IBM MobileFirst Platform",
|
||||
"userEnrollmentUnsupportedOS" : "כשל באימות אישור משתמש: פלטפורמת לקוח לא נתמכת.",
|
||||
"failureCallingMethod" : "כשל בקריאה למתודה {0}",
|
||||
"challengeHandlingCanceled" : "Challenge handler operation was cancelled.",
|
||||
"unsupportedEnvironment" : "סביבה לא נתמכת",
|
||||
"redirect" : "ניתוב"
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "PII user facing" ,
|
||||
"accessDenied" : "Accesso negato",
|
||||
"authFailure" : "È stato rilevato un errore durante l'elaborazione della richiesta dall'applicazione",
|
||||
"applicationDenied" : "Applicazione disabilitata",
|
||||
"browserIsNotSupported" : "{0} non è attualmente supportato.",
|
||||
"cancel" : "Annulla",
|
||||
"close" : "Chiudi",
|
||||
"cookiesAreDisabled" : "Attualmente i cookie sono disabilitati nel browser in uso. È necessario abilitarli per un corretto funzionamento dell'applicazione.",
|
||||
"copyToClipboard" : "Copia",
|
||||
"details" : "Dettagli",
|
||||
"diagApp" : "Diagnostica app",
|
||||
"diagTime" : "Ora",
|
||||
"diagApplicationName" : "Nome applicazione",
|
||||
"diagApplicationVersion" : "Versione applicazione",
|
||||
"diagServiceURL" : "URL servizio",
|
||||
"diagDevicePlatform" : "Piattaforma dispositivo",
|
||||
"diagDeviceVersion" : "Versione dispositivo",
|
||||
"diagScreenResolution" : "Risoluzione schermo",
|
||||
"diagAirplaneMode" : "Modalità aereo",
|
||||
"diagUsingNetwork" : "Utilizzo della rete",
|
||||
"diagWifiName" : "Nome WiFi",
|
||||
"diagMobileNetworkType" : "Tipo di rete mobile",
|
||||
"diagCarrierName" : "Nome vettore",
|
||||
"diagErrorCode" : "Codice di errore",
|
||||
"diagErrorMessage" : "Messaggio di errore",
|
||||
"diagHttpStatus" : "Stato HTTP",
|
||||
"diagIPAddress" : "Indirizzo IP",
|
||||
"directUpdateNotificationTitle" : "Aggiornamento disponibile",
|
||||
"directUpdateNotificationMessage" : "Sono disponibili nuove risorse web. Confermare l'aggiornamento (la dimensione file è {0} MB).",
|
||||
"directUpdateNotificationMessageKilobytes" : "Sono disponibili nuove risorse web. Confermare l'aggiornamento (la dimensione file è {0} KB).",
|
||||
"directUpdateErrorTitle" : "Aggiornamento non riuscito",
|
||||
"directUpdateErrorMessage" : "Errore dell'aggiornamento diretto.",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "È disponibile un aggiornamento per l'applicazione, ma lo spazio disponibile sul dispositivo non è sufficiente (dimensione richiesta: {0} MB, spazio disponibile: {1} MB).",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "Download del file di aggiornamento dell'applicazione non riuscito.",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "Elaborazione del file di aggiornamento dell'applicazione non riuscita.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "Impossibile scaricare le risorse app. Specificare l'ID app nella schermata Impostazioni.",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "Impossibile trovare l'applicazione '{0}'. Eseguire prima la distribuzione su IBM MobileFirst Platform Server.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "Impossibile scaricare le risorse app. Specificare la versione app nella schermata Impostazioni.",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "Impossibile scaricare le risorse app. skin: {0} non esistente. Assicurarsi che getSkinName() sia risolto in uno skin valido.",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "Impossibile trovare l'applicazione '{0}' {1} per {2}",
|
||||
"deviceAuthenticationFail" : "Errore di connettività",
|
||||
"saveCertificateFailure" : "Impossibile salvare il certificato",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "Una connessione al server non è disponibile. Impossibile scaricare le risorse dell'applicazione.",
|
||||
"expandWindow" : "Espandere l'applicazione per utilizzarla",
|
||||
"exit" : "Esci",
|
||||
"exitApplication" : "Esci dall'applicazione",
|
||||
"error" : "Errore",
|
||||
"gadgetUpdateAvailable" : "Aggiornamento dell'applicazione disponibile",
|
||||
"getNewVersion" : "Ottieni nuova versione",
|
||||
"handleTimeOut" : "Richiesta scaduta per {0}. Assicurarsi che l'indirizzo host sia disponibile per l'applicazione (particolarmente importante per le app di Android e iPhone).",
|
||||
"invalidUsernamePassword" : "Nome utente o password non validi",
|
||||
"keepAliveInBackgroundText" : "L'esecuzione dell'applicazione prosegue in background",
|
||||
"loading" : "Caricamento",
|
||||
"login" : "Accesso",
|
||||
"minimize" : "Riduci al minimo",
|
||||
"missingFeatureException" : "Chiamata a {1} non riuscita perché {0} non è presente nell'applicazione. Aggiungere {0} al descrittore dell'applicazione, crearla nuovamente e distribuirla.",
|
||||
"name" : "Nome:",
|
||||
"noInternet" : "La connessione al servizio non è disponibile.",
|
||||
"notificationTitle" : "Notifica del servizio",
|
||||
"notAvailable" : "Non disponibile",
|
||||
"ok" : "OK",
|
||||
"password" : "Password:",
|
||||
"reload" : "Ricarica",
|
||||
"restore" : "Ripristina",
|
||||
"requestTimeout" : "L'applicazione non è riuscita ad effettuare la connessione al servizio.",
|
||||
"responseNotRecognized" : "Risposta non prevista.",
|
||||
"settings" : "Impostazioni",
|
||||
"serverError" : "Errore di richiamo procedura.",
|
||||
"tryAgain" : "Riprova",
|
||||
"userInstanceAccessViolationException" : "Si sta cercando di collegarsi a un'applicazione a cui non si è registrati.",
|
||||
"unexpectedError" : "Il server non è riuscito a elaborare la richiesta dall'applicazione. Riprovare successivamente.",
|
||||
"unresponsiveHost" : "Il servizio attualmente non è disponibile.",
|
||||
"update" : "Aggiorna",
|
||||
"upgrade" : "Esegui l'upgrade",
|
||||
"upgradeGadget" : "La versione dell'applicazione è {0}. È disponibile la versione {1} di questa applicazione. Fare clic su OK per scaricare e installare.",
|
||||
"wlclientInitFailure" : "Errore",
|
||||
"wlSettings" : "Impostazioni di IBM MobileFirst Platform",
|
||||
"userEnrollmentUnsupportedOS" : "Errore di autenticazione del certificato utente: piattaforma client non supportata.",
|
||||
"failureCallingMethod" : "Errore durante il richiamo di {0}",
|
||||
"challengeHandlingCanceled" : "Operazione Challenge Handler annullata.",
|
||||
"unsupportedEnvironment" : "Ambiente non supportato",
|
||||
"redirect" : "Reindirizza"
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "PII ユーザー・インターフェース" ,
|
||||
"accessDenied" : "アクセスは拒否されました",
|
||||
"authFailure" : "アプリケーションからの要求の処理中にエラーが発生しました。",
|
||||
"applicationDenied" : "アプリケーションは使用できません",
|
||||
"browserIsNotSupported" : "{0} は現在サポートされていません。",
|
||||
"cancel" : "キャンセル",
|
||||
"close" : "閉じる",
|
||||
"cookiesAreDisabled" : "Cookie は現在ご使用のブラウザーで無効になっています。 これらを有効にしてアプリケーションが適切に機能するようにしてください。",
|
||||
"copyToClipboard" : "コピー",
|
||||
"details" : "詳細",
|
||||
"diagApp" : "アプリケーション診断",
|
||||
"diagTime" : "時刻",
|
||||
"diagApplicationName" : "アプリケーション名",
|
||||
"diagApplicationVersion" : "アプリケーション・バージョン",
|
||||
"diagServiceURL" : "サービス URL",
|
||||
"diagDevicePlatform" : "デバイス・プラットフォーム",
|
||||
"diagDeviceVersion" : "デバイス・バージョン",
|
||||
"diagScreenResolution" : "画面解像度",
|
||||
"diagAirplaneMode" : "機内モード",
|
||||
"diagUsingNetwork" : "ネットワークの使用",
|
||||
"diagWifiName" : "WiFi 名",
|
||||
"diagMobileNetworkType" : "モバイル・ネットワーク・タイプ",
|
||||
"diagCarrierName" : "通信事業者名",
|
||||
"diagErrorCode" : "エラー・コード",
|
||||
"diagErrorMessage" : "エラー・メッセージ",
|
||||
"diagHttpStatus" : "HTTP 状況",
|
||||
"diagIPAddress" : "IP アドレス",
|
||||
"directUpdateNotificationTitle" : "更新が利用可能",
|
||||
"directUpdateNotificationMessage" : "より新しい Web リソースが利用可能です。 確認して更新してください。 (ファイル・サイズ {0} MB)",
|
||||
"directUpdateNotificationMessageKilobytes" : "より新しい Web リソースが利用可能です。 確認して更新してください。 (ファイル・サイズ {0} KB)",
|
||||
"directUpdateErrorTitle" : "更新が失敗",
|
||||
"directUpdateErrorMessage" : "直接の更新が失敗しました。",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "アプリケーションの更新が利用可能ですが、デバイス上に十分な使用可能スペースがありません (必要なサイズ: {0} MB、使用可能スペース: {1} MB)。",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "アプリケーション更新ファイルのダウンロードが失敗しました。",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "アプリケーション更新ファイルの処理が失敗しました。",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "アプリケーション・リソースをダウンロードできません。 「設定」画面の「アプリケーション ID」を指定してください。",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "アプリケーション '{0}' が見つかりません。 最初にそれを IBM MobileFirst Platform Server にデプロイしてください。",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "アプリケーション・リソースをダウンロードできません。 「設定」画面の「アプリケーション・バージョン」を指定してください。",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "アプリケーション・リソースをダウンロードできません。 スキン: {0} は存在しません。 getSkinName() の値が確実に有効なスキンになるようにしてください。",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "アプリケーション '{0}' {1} ({2} 用) が見つかりません",
|
||||
"deviceAuthenticationFail" : "接続エラー",
|
||||
"saveCertificateFailure" : "証明書を保存できません",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "サーバーに接続できません。 アプリケーション・リソースをダウンロードできません。",
|
||||
"expandWindow" : "アプリケーションを展開して使用してください",
|
||||
"exit" : "終了",
|
||||
"exitApplication" : "アプリケーションの終了",
|
||||
"error" : "エラー",
|
||||
"gadgetUpdateAvailable" : "アプリケーションの更新が利用可能です",
|
||||
"getNewVersion" : "新バージョンの入手",
|
||||
"handleTimeOut" : "{0} の要求がタイムアウトになりました。 ホスト・アドレスがアプリケーション (特に Android や iPhone のアプリケーション) で使用できることを確認してください。",
|
||||
"invalidUsernamePassword" : "無効なユーザー名またはパスワード",
|
||||
"keepAliveInBackgroundText" : "アプリケーションはバックグラウンドで引き続き稼働中",
|
||||
"loading" : "ロード中",
|
||||
"login" : "ログイン",
|
||||
"minimize" : "最小化",
|
||||
"missingFeatureException" : "アプリケーションに {0} がないため {1} の呼び出しに失敗しました。 アプリケーション記述子に {0} を追加し、再ビルドしデプロイしてください。",
|
||||
"name" : "名前:",
|
||||
"noInternet" : "サービスに接続できません。",
|
||||
"notificationTitle" : "サービス通知",
|
||||
"notAvailable" : "使用不可",
|
||||
"ok" : "OK",
|
||||
"password" : "パスワード:",
|
||||
"reload" : "再ロード",
|
||||
"restore" : "復元",
|
||||
"requestTimeout" : "アプリケーションがサービスへの接続に失敗しました。",
|
||||
"responseNotRecognized" : "予期しない応答。",
|
||||
"settings" : "設定",
|
||||
"serverError" : "プロシージャー呼び出しエラー。",
|
||||
"tryAgain" : "やり直してください",
|
||||
"userInstanceAccessViolationException" : "登録されていないアプリケーションにログインしようとしています。",
|
||||
"unexpectedError" : "サーバーはアプリケーションからの要求を処理できませんでした。 後でもう一度やり直してください。",
|
||||
"unresponsiveHost" : "サービスは現在使用できません。",
|
||||
"update" : "更新",
|
||||
"upgrade" : "アップグレード",
|
||||
"upgradeGadget" : "ご使用のアプリケーションのバージョンは {0} です。 このアプリケーションのバージョン {1} が使用可能です。 これをダウンロードしてインストールするには「OK」をクリックしてください。",
|
||||
"wlclientInitFailure" : "エラー",
|
||||
"wlSettings" : "IBM MobileFirst Platform の設定",
|
||||
"userEnrollmentUnsupportedOS" : "ユーザー証明書認証障害: サポートされていないクライアント・プラットフォーム。",
|
||||
"failureCallingMethod" : "障害呼び出し {0}",
|
||||
"challengeHandlingCanceled" : "Challenge handler の操作がキャンセルされました。",
|
||||
"unsupportedEnvironment" : "非サポート環境",
|
||||
"redirect" : "リダイレクト"
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "PII 사용자 지향" ,
|
||||
"accessDenied" : "액세스 거부됨",
|
||||
"authFailure" : "애플리케이션의 요청을 처리하는 중에 오류가 발생했습니다.",
|
||||
"applicationDenied" : "애플리케이션 사용 안함",
|
||||
"browserIsNotSupported" : "{0}은(는) 현재 지원되지 않습니다.",
|
||||
"cancel" : "취소",
|
||||
"close" : "닫기",
|
||||
"cookiesAreDisabled" : "쿠키는 브라우저에서 현재 사용되지 않습니다. 애플리케이션이 제대로 작동하려면 쿠키를 사용해야 합니다.",
|
||||
"copyToClipboard" : "복사",
|
||||
"details" : "세부사항",
|
||||
"diagApp" : "애플리케이션 진단",
|
||||
"diagTime" : "시간",
|
||||
"diagApplicationName" : "애플리케이션 이름",
|
||||
"diagApplicationVersion" : "애플리케이션 버전",
|
||||
"diagServiceURL" : "서비스 URL",
|
||||
"diagDevicePlatform" : "디바이스 플랫폼",
|
||||
"diagDeviceVersion" : "디바이스 버전",
|
||||
"diagScreenResolution" : "화면 해상도",
|
||||
"diagAirplaneMode" : "통신제한 모드",
|
||||
"diagUsingNetwork" : "사용 중인 네트워크",
|
||||
"diagWifiName" : "WiFi 이름",
|
||||
"diagMobileNetworkType" : "모바일 네트워크 유형",
|
||||
"diagCarrierName" : "통신회사 이름",
|
||||
"diagErrorCode" : "오류 코드",
|
||||
"diagErrorMessage" : "오류 메시지",
|
||||
"diagHttpStatus" : "HTTP 상태",
|
||||
"diagIPAddress" : "IP 주소",
|
||||
"directUpdateNotificationTitle" : "업데이트 사용 가능",
|
||||
"directUpdateNotificationMessage" : "최신 웹 자원이 사용 가능합니다. 업데이트 확인(파일 크기: {0}MB).",
|
||||
"directUpdateNotificationMessageKilobytes" : "최신 웹 자원이 사용 가능합니다. 업데이트 확인(파일 크기: {0}KB).",
|
||||
"directUpdateErrorTitle" : "업데이트 실패",
|
||||
"directUpdateErrorMessage" : "직접 업데이트에 실패했습니다.",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "애플리케이션에 대한 업데이트를 사용할 수 있지만 디바이스의 사용 가능한 공간이 충분하지 않습니다(필수 크기: {0}MB, 사용 가능한 공간: {1} MB).",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "애플리케이션 업데이트 파일을 다운로드하는 데 실패했습니다.",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "애플리케이션 업데이트 파일을 처리하는 데 실패했습니다.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "애플리케이션 자원을 다운로드할 수 없습니다. 설정 화면에서 애플리케이션 ID를 지정하십시오.",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "'{0}' 애플리케이션을 찾을 수 없습니다. 먼저 IBM MobileFirst Platform Server에 해당 애플리케이션을 배치하십시오.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "애플리케이션 자원을 다운로드할 수 없습니다. 설정 화면에서 애플리케이션 버전을 지정하십시오.",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "애플리케이션 자원을 다운로드할 수 없습니다. {0} 스킨이 존재하지 않습니다. getSkinName()이 올바른 스킨에 해석되는지 확인하십시오.",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "{2}용 '{0}' {1} 애플리케이션을 찾을 수 없습니다. ",
|
||||
"deviceAuthenticationFail" : "연결성 오류",
|
||||
"saveCertificateFailure" : "인증서를 저장할 수 없습니다.",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "서버에 연결할 수 없습니다. 애플리케이션 자원을 다운로드할 수 없습니다.",
|
||||
"expandWindow" : "사용할 애플리케이션 펼치기",
|
||||
"exit" : "종료",
|
||||
"exitApplication" : "애플리케이션 종료",
|
||||
"error" : "오류",
|
||||
"gadgetUpdateAvailable" : "애플리케이션 업데이트 사용 가능",
|
||||
"getNewVersion" : "새 버전 가져오기",
|
||||
"handleTimeOut" : "{0}에 대한 요청 제한시간이 초과되었습니다. 애플리케이션에 대한 호스트 주소가 사용 가능한지 확인하십시오(특히 Android 및 iPhone 애플리케이션 관련).",
|
||||
"invalidUsernamePassword" : "사용자 이름 또는 비밀번호가 올바르지 않음",
|
||||
"keepAliveInBackgroundText" : "애플리케이션이 배경에서 계속 실행됨",
|
||||
"loading" : "로드 중",
|
||||
"login" : "로그인",
|
||||
"minimize" : "최소화",
|
||||
"missingFeatureException" : "애플리케이션에서 {0}이(가) 누락되어 {1} 호출에 실패했습니다. 애플리케이션 디스크립터에 {0}을(를) 추가하고 다시 빌드하여 배치하십시오. ",
|
||||
"name" : "이름:",
|
||||
"noInternet" : "서비스에 대한 연결을 사용할 수 없습니다.",
|
||||
"notificationTitle" : "서비스 알림",
|
||||
"notAvailable" : "사용할 수 없음",
|
||||
"ok" : "확인",
|
||||
"password" : "비밀번호:",
|
||||
"reload" : "다시 로드",
|
||||
"restore" : "복원",
|
||||
"requestTimeout" : "애플리케이션에서 서비스 연결에 실패했습니다.",
|
||||
"responseNotRecognized" : "예상치 못한 응답입니다.",
|
||||
"settings" : "설정",
|
||||
"serverError" : "프로시저 호출 오류입니다.",
|
||||
"tryAgain" : "다시 시도",
|
||||
"userInstanceAccessViolationException" : "등록되지 않은 애플리케이션에 로그인하는 중입니다.",
|
||||
"unexpectedError" : "서버는 애플리케이션의 요청을 처리할 수 없습니다. 나중에 다시 시도하십시오.",
|
||||
"unresponsiveHost" : "서비스를 현재 사용할 수 없습니다.",
|
||||
"update" : "업데이트",
|
||||
"upgrade" : "업그레이드",
|
||||
"upgradeGadget" : "사용자의 애플리케이션 버전은 {0}입니다. 이 애플리케이션의 {1} 버전을 사용할 수 있습니다. 해당 버전을 다운로드하여 설치하려면 확인을 클릭하십시오.",
|
||||
"wlclientInitFailure" : "오류",
|
||||
"wlSettings" : "IBM MobileFirst Platform 설정",
|
||||
"userEnrollmentUnsupportedOS" : "사용자 인증 실패: 지원되지 않는 클라이언트 플랫폼",
|
||||
"failureCallingMethod" : "{0} 호출 실패",
|
||||
"challengeHandlingCanceled" : "인증 확인 핸들러 조작이 취소되었습니다.",
|
||||
"unsupportedEnvironment" : "지원되지 않는 환경",
|
||||
"redirect" : "경로 재지정"
|
||||
}
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "PII user facing" ,
|
||||
"accessDenied" : "Access Denied",
|
||||
"authFailure" : "An error was encountered while processing the request from the application.",
|
||||
"applicationDenied" : "Application Disabled",
|
||||
"browserIsNotSupported" : "{0} is currently not supported.",
|
||||
"cancel" : "Cancel",
|
||||
"close" : "Close",
|
||||
"cookiesAreDisabled" : "Cookies are currently disabled in your browser. You must enable them for the application to function properly.",
|
||||
"copyToClipboard" : "Copy",
|
||||
"details" : "Details",
|
||||
"diagApp" : "App Diagnostics",
|
||||
"diagTime" : "Time",
|
||||
"diagApplicationName" : "Application Name",
|
||||
"diagApplicationVersion" : "Application Version",
|
||||
"diagServiceURL" : "Service URL",
|
||||
"diagDevicePlatform" : "Device Platform",
|
||||
"diagDeviceVersion" : "Device Version",
|
||||
"diagScreenResolution" : "Screen Resolution",
|
||||
"diagAirplaneMode" : "Airplane Mode",
|
||||
"diagUsingNetwork" : "Using Network",
|
||||
"diagWifiName" : "WiFi Name",
|
||||
"diagMobileNetworkType" : "Mobile Network Type",
|
||||
"diagCarrierName" : "Carrier Name",
|
||||
"diagErrorCode" : "Error Code",
|
||||
"diagErrorMessage" : "Error Message",
|
||||
"diagHttpStatus" : "HTTP Status",
|
||||
"diagIPAddress" : "IP Address",
|
||||
"directUpdateNotificationTitle" : "Update available",
|
||||
"directUpdateNotificationMessage" : "Newer web resources are available. Confirm to update. (file size is {0} MB).",
|
||||
"directUpdateNotificationMessageKilobytes" : "Newer web resources are available. Confirm to update. (file size is {0} KB).",
|
||||
"directUpdateErrorTitle" : "Update Failed",
|
||||
"directUpdateErrorMessage" : "Direct Update failure.",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "An update for the application is available, but there is not enough space available on the device (required size: {0} MB, available space: {1} MB).",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "Failed downloading application update file.",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "Failed processing application update file.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "Cannot download app resources. Specify the App ID in the Settings screen.",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "Application '{0}' cannot be found. Deploy it first to the IBM MobileFirst Platform Server.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "Cannot download app resources. Specify the App Version in the Settings screen.",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "Cannot download app resources. skin: {0} does not exist. Please make sure getSkinName() resolves to a valid skin.",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "Cannot find application '{0}' {1} for {2}",
|
||||
"deviceAuthenticationFail" : "Connectivity Error",
|
||||
"saveCertificateFailure" : "Unable to save certificate",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "A connection to the server is not available. Cannot download application resources.",
|
||||
"expandWindow" : "Expand application to use it",
|
||||
"exit" : "Exit",
|
||||
"exitApplication" : "Exit application",
|
||||
"error" : "Error",
|
||||
"gadgetUpdateAvailable" : "Application update available",
|
||||
"getNewVersion" : "Get new version",
|
||||
"handleTimeOut" : "Request timed out for {0}. Make sure the host address is available to the application (especially relevant for Android and iPhone apps).",
|
||||
"invalidUsernamePassword" : "Invalid user name or password",
|
||||
"keepAliveInBackgroundText" : "Application keeps running in background",
|
||||
"loading" : "Loading",
|
||||
"login" : "Login",
|
||||
"minimize" : "Minimize",
|
||||
"missingFeatureException" : "Failed to call {1} because {0} is missing in the application. Add {0} to the application descriptor, rebuild and deploy it.",
|
||||
"name" : "Name:",
|
||||
"noInternet" : "Connection to the service is not available.",
|
||||
"notificationTitle" : "Service Notification",
|
||||
"notAvailable" : "Not Available",
|
||||
"ok" : "OK",
|
||||
"password" : "Password:",
|
||||
"reload" : "Reload",
|
||||
"restore" : "Restore",
|
||||
"requestTimeout" : "The application failed connecting to the service.",
|
||||
"responseNotRecognized" : "Unexpected response.",
|
||||
"settings" : "Settings",
|
||||
"serverError" : "Procedure invocation error.",
|
||||
"tryAgain" : "Try Again",
|
||||
"userInstanceAccessViolationException" : "You are trying to login to an application that is not registered for you.",
|
||||
"unexpectedError" : "The server was unable to process the request from the application. Please try again later.",
|
||||
"unresponsiveHost" : "The service is currently not available.",
|
||||
"update" : "Update",
|
||||
"upgrade" : "Upgrade",
|
||||
"upgradeGadget" : "The version of your application is {0}. Version {1} of this application is available. Click OK to download and install it.",
|
||||
"wlclientInitFailure" : "Error",
|
||||
"wlSettings" : "IBM MobileFirst Platform Settings",
|
||||
"userEnrollmentUnsupportedOS" : "User certificate authentication failure: unsupported client platform.",
|
||||
"failureCallingMethod" : "Failure calling {0}",
|
||||
"challengeHandlingCanceled" : "Challenge handler operation was cancelled.",
|
||||
"unsupportedEnvironment" : "Unsupported environment",
|
||||
"redirect" : "Redirect"
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "Face de Usuário de PII" ,
|
||||
"accessDenied" : "Acesso Negado",
|
||||
"authFailure" : "Um erro foi encontrado ao processar a solicitação do aplicativo.",
|
||||
"applicationDenied" : "Aplicativo Desativado",
|
||||
"browserIsNotSupported" : "{0} não é suportado atualmente.",
|
||||
"cancel" : "Cancelar",
|
||||
"close" : "Fechar",
|
||||
"cookiesAreDisabled" : "Os cookies estão atualmente desativados em seu navegador. Você deve ativá-los para que o aplicativo funcione adequadamente.",
|
||||
"copyToClipboard" : "Copiar",
|
||||
"details" : "Detalhes",
|
||||
"diagApp" : "Diagnósticos do Aplicativo",
|
||||
"diagTime" : "Tempo",
|
||||
"diagApplicationName" : "Nome do Aplicativo",
|
||||
"diagApplicationVersion" : "Versão do Aplicativo",
|
||||
"diagServiceURL" : "URL de Serviço",
|
||||
"diagDevicePlatform" : "Plataforma do Dispositivo",
|
||||
"diagDeviceVersion" : "Versão do Dispositivo",
|
||||
"diagScreenResolution" : "Resolução da Tela",
|
||||
"diagAirplaneMode" : "Modo de Avião",
|
||||
"diagUsingNetwork" : "Usando Rede",
|
||||
"diagWifiName" : "Nome da WiFi",
|
||||
"diagMobileNetworkType" : "Tipo de Rede Remota",
|
||||
"diagCarrierName" : "Nome da Transportadora",
|
||||
"diagErrorCode" : "Código de Erro",
|
||||
"diagErrorMessage" : "Mensagem de Erro",
|
||||
"diagHttpStatus" : "Status de HTTP",
|
||||
"diagIPAddress" : "Endereço IP",
|
||||
"directUpdateNotificationTitle" : "Atualização disponível",
|
||||
"directUpdateNotificationMessage" : "Recursos da web mais recentes estão disponíveis. Confirme para atualizar. (o tamanho do arquivo é de {0} MB).",
|
||||
"directUpdateNotificationMessageKilobytes" : "Recursos da web mais recentes estão disponíveis. Confirme para atualizar. (o tamanho do arquivo é de {0} KB).",
|
||||
"directUpdateErrorTitle" : "Atualização com Falha",
|
||||
"directUpdateErrorMessage" : "Falha na Atualização Direta.",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "Uma atualização para o aplicativo está disponível, mas não há espaço suficiente disponível no dispositivo (tamanho necessário: {0} MB, espaço disponível: {1} MB).",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "Falha ao fazer download do arquivo de atualização do aplicativo.",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "Falha ao processar o arquivo de atualização do aplicativo.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "Não é possível fazer download de recursos do aplicativo. Especifique o ID do Aplicativo na tela Configurações.",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "O aplicativo '{0}' não pode ser localizado. Implemente-o primeiro no IBM MobileFirst Platform Server.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "Não é possível fazer download de recursos do aplicativo. Especifique a Versão do Aplicativo na tela Configurações.",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "Não é possível fazer download de recursos do aplicativo. Aparência: {0} não existe. Certifique-se de que getSkinName() seja resolvido para uma aparência válida.",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "Não é possível localizar o aplicativo '{0}' {1} para {2}",
|
||||
"deviceAuthenticationFail" : "Erro de Conectividade",
|
||||
"saveCertificateFailure" : "Não é possível salvar o certificado",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "Uma conexão com o servidor não está disponível. Não é possível fazer download de recursos do aplicativo.",
|
||||
"expandWindow" : "Expandir aplicativo para usá-lo",
|
||||
"exit" : "Sair",
|
||||
"exitApplication" : "Sair do Aplicativo",
|
||||
"error" : "Erro",
|
||||
"gadgetUpdateAvailable" : "Atualização do aplicativo disponível",
|
||||
"getNewVersion" : "Obter Nova Versão",
|
||||
"handleTimeOut" : "A solicitação atingiu o tempo limite para {0}. Certifique-se de que o endereço do host esteja disponível para o aplicativo (especialmente relevante para aplicativos Android e iPhone).",
|
||||
"invalidUsernamePassword" : "Nome de usuário ou senha inválida",
|
||||
"keepAliveInBackgroundText" : "O aplicativo continua em execução no segundo plano",
|
||||
"loading" : "Carregando",
|
||||
"login" : "Login",
|
||||
"minimize" : "Minimizar",
|
||||
"missingFeatureException" : "Falha ao chamar {1} porque {0} está ausente no aplicativo. Inclua {0} no descritor de aplicativo, reconstrua e implemente-o.",
|
||||
"name" : "Nome:",
|
||||
"noInternet" : "A conexão com o serviço não está disponível.",
|
||||
"notificationTitle" : "Notificação de Serviço",
|
||||
"notAvailable" : "Não Disponível",
|
||||
"ok" : "OK",
|
||||
"password" : "Senha:",
|
||||
"reload" : "Recarregar",
|
||||
"restore" : "Restaurar",
|
||||
"requestTimeout" : "Falha ao conectar o aplicativo com o serviço.",
|
||||
"responseNotRecognized" : "Resposta inesperada.",
|
||||
"settings" : "Configurações",
|
||||
"serverError" : "Erro de chamada de procedimento.",
|
||||
"tryAgain" : "Tentar Novamente",
|
||||
"userInstanceAccessViolationException" : "Você está tentando efetuar login em um aplicativo que não está registrado para você.",
|
||||
"unexpectedError" : "O servidor não pôde processar a solicitação do aplicativo. Tente novamente mais tarde.",
|
||||
"unresponsiveHost" : "O serviço não está atualmente disponível.",
|
||||
"update" : "Atualizar",
|
||||
"upgrade" : "Fazer Upgrade",
|
||||
"upgradeGadget" : "A versão de seu aplicativo é {0}. A versão {1} deste aplicativo está disponível. Clique em OK para fazer download e instalá-la.",
|
||||
"wlclientInitFailure" : "Erro",
|
||||
"wlSettings" : "Configurações do IBM MobileFirst Platform",
|
||||
"userEnrollmentUnsupportedOS" : "Falha de autenticação de certificado de usuário: plataforma do cliente não suportada.",
|
||||
"failureCallingMethod" : "Falha ao chamar {0}",
|
||||
"challengeHandlingCanceled" : "A operação do manipulador de desafios foi cancelada.",
|
||||
"unsupportedEnvironment" : "Ambiente não suportado",
|
||||
"redirect" : "Redirecionar"
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "Личные данные для пользователя" ,
|
||||
"accessDenied" : "Доступ запрещен",
|
||||
"authFailure" : "Произошла ошибка при обработке запроса из приложения.",
|
||||
"applicationDenied" : "Приложение выключено",
|
||||
"browserIsNotSupported" : "{0} в настоящее время не поддерживается.",
|
||||
"cancel" : "Отмена",
|
||||
"close" : "Закрыть",
|
||||
"cookiesAreDisabled" : "В данный момент cookie в браузере выключены. Их необходимо включить, чтобы обеспечить правильную работу приложения.",
|
||||
"copyToClipboard" : "Копировать",
|
||||
"details" : "Сведения",
|
||||
"diagApp" : "Диагностика приложения",
|
||||
"diagTime" : "Время",
|
||||
"diagApplicationName" : "Имя приложения",
|
||||
"diagApplicationVersion" : "Версия приложения",
|
||||
"diagServiceURL" : "URL службы",
|
||||
"diagDevicePlatform" : "Платформа",
|
||||
"diagDeviceVersion" : "Версия устройства",
|
||||
"diagScreenResolution" : "Разрешение экрана",
|
||||
"diagAirplaneMode" : "Режим самолета",
|
||||
"diagUsingNetwork" : "Работа с сетью",
|
||||
"diagWifiName" : "Имя WiFi",
|
||||
"diagMobileNetworkType" : "Тип моб. сети",
|
||||
"diagCarrierName" : "Назв. носителя",
|
||||
"diagErrorCode" : "Код ошибки",
|
||||
"diagErrorMessage" : "Сообщение",
|
||||
"diagHttpStatus" : "Состояние HTTP",
|
||||
"diagIPAddress" : "IP-адрес",
|
||||
"directUpdateNotificationTitle" : "Есть обновление",
|
||||
"directUpdateNotificationMessage" : "Доступные новые веб-ресурсы. Подтвердите обновление. (Размер файла: {0} МБ).",
|
||||
"directUpdateNotificationMessageKilobytes" : "Доступные новые веб-ресурсы. Подтвердите обновление. (Размер файла: {0} КБ).",
|
||||
"directUpdateErrorTitle" : "Обновление не выполнено",
|
||||
"directUpdateErrorMessage" : "Сбой прямого обновления.",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "Для приложения доступно обновление, но в устройстве недостаточно памяти (необходимый объем: {0} МБ, доступно: {1} МБ).",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "Не удалось загрузить файл обновления приложения.",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "Не удалось обработать файл обновления приложения.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "Невозможно загрузить ресурсы приложения. Укажите ИД приложения в окне Параметры.",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "Приложение '{0}' не найдено. Разверните его сначала на сервере IBM MobileFirst Platform.",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "Невозможно загрузить ресурсы приложения. Укажите версию приложения в окне Параметры.",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "Невозможно загрузить ресурсы приложения. оболочка {0} не существует. Убедитесь, что getSkinName() преобразуется в правильную оболочку.",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "Не найдено приложение '{0}' {1} для {2}",
|
||||
"deviceAuthenticationFail" : "Ошибка соединения",
|
||||
"saveCertificateFailure" : "Не удалось сохранить сертификат",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "Соединение с сервером недоступно. Невозможно загрузить ресурсы приложения.",
|
||||
"expandWindow" : "Разверните приложение для работы с ним",
|
||||
"exit" : "Выход",
|
||||
"exitApplication" : "Закрыть приложение",
|
||||
"error" : "Ошибка",
|
||||
"gadgetUpdateAvailable" : "Доступно обновление приложения",
|
||||
"getNewVersion" : "Получить новую версию",
|
||||
"handleTimeOut" : "Тайм-аут запроса для {0}. Убедитесь, что адрес хоста доступен для приложения (особенно при работе с приложениями Android и iPhone).",
|
||||
"invalidUsernamePassword" : "Недопустимое имя пользователя или пароль",
|
||||
"keepAliveInBackgroundText" : "Приложение продолжает выполняться в фоновом режиме",
|
||||
"loading" : "Загрузка",
|
||||
"login" : "Вход в систему",
|
||||
"minimize" : "Свернуть",
|
||||
"missingFeatureException" : "Не удалось вызвать {1}, так как в приложении отсутствует {0}. Добавьте {0} в файл описания приложения, перекомпонуйте его и выполните развертывание.",
|
||||
"name" : "Имя:",
|
||||
"noInternet" : "Соединение со службой недоступно.",
|
||||
"notificationTitle" : "Уведомление об обслуживании",
|
||||
"notAvailable" : "Недоступно",
|
||||
"ok" : "OK",
|
||||
"password" : "Пароль:",
|
||||
"reload" : "Заново",
|
||||
"restore" : "Восстановить",
|
||||
"requestTimeout" : "Приложению не удалось подключиться к службе.",
|
||||
"responseNotRecognized" : "Непредвиденный ответ.",
|
||||
"settings" : "Параметры",
|
||||
"serverError" : "Ошибка вызова процедуры.",
|
||||
"tryAgain" : "Повторите попытку",
|
||||
"userInstanceAccessViolationException" : "Попытка входа в систему приложения, которое для вас не зарегистрировано.",
|
||||
"unexpectedError" : "Серверу не удалось обработать запрос из приложения. Повторите операцию позднее.",
|
||||
"unresponsiveHost" : "В данный момент служба недоступна.",
|
||||
"update" : "Обновить",
|
||||
"upgrade" : "Обновить",
|
||||
"upgradeGadget" : "Приложение имеет версию {0}. Доступна версия {1} этого приложения. Для загрузки и установки нажмите OK.",
|
||||
"wlclientInitFailure" : "Ошибка",
|
||||
"wlSettings" : "Параметры платформы IBM MobileFirst",
|
||||
"userEnrollmentUnsupportedOS" : "Ошибка сертификата пользователя: неподдерживаемая платформа клиента.",
|
||||
"failureCallingMethod" : "Ошибка вызова {0}",
|
||||
"challengeHandlingCanceled" : "Операция обработчика вызовов была отменена.",
|
||||
"unsupportedEnvironment" : "Неподдерживаемая среда",
|
||||
"redirect" : "Перенаправление"
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "PII 使用者樣式" ,
|
||||
"accessDenied" : "拒絕存取",
|
||||
"authFailure" : "處理應用程式的要求時發生錯誤。",
|
||||
"applicationDenied" : "應用程式已停用",
|
||||
"browserIsNotSupported" : "目前不支援 {0}。",
|
||||
"cancel" : "取消",
|
||||
"close" : "關閉",
|
||||
"cookiesAreDisabled" : "您的瀏覽器目前已停用 Cookie。 您必須加以啟用,應用程式才能正常運作。",
|
||||
"copyToClipboard" : "複製",
|
||||
"details" : "詳細資料",
|
||||
"diagApp" : "應用程式診斷程式",
|
||||
"diagTime" : "時間",
|
||||
"diagApplicationName" : "應用程式名稱",
|
||||
"diagApplicationVersion" : "應用程式版本",
|
||||
"diagServiceURL" : "服務 URL",
|
||||
"diagDevicePlatform" : "裝置平台",
|
||||
"diagDeviceVersion" : "裝置版本",
|
||||
"diagScreenResolution" : "螢幕解析度",
|
||||
"diagAirplaneMode" : "飛航模式",
|
||||
"diagUsingNetwork" : "使用網路",
|
||||
"diagWifiName" : "WiFi 名稱",
|
||||
"diagMobileNetworkType" : "行動網路類型",
|
||||
"diagCarrierName" : "電信業者名稱",
|
||||
"diagErrorCode" : "錯誤碼",
|
||||
"diagErrorMessage" : "錯誤訊息",
|
||||
"diagHttpStatus" : "HTTP 狀態",
|
||||
"diagIPAddress" : "IP 位址",
|
||||
"directUpdateNotificationTitle" : "有可用的更新項目",
|
||||
"directUpdateNotificationMessage" : "有可用的新版 Web 資源。確認以更新。(檔案大小為 {0} MB)。",
|
||||
"directUpdateNotificationMessageKilobytes" : "有可用的新版 Web 資源。確認以更新。(檔案大小為 {0} KB)。",
|
||||
"directUpdateErrorTitle" : "更新失敗",
|
||||
"directUpdateErrorMessage" : "直接更新失敗。",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "有可用的應用程式更新,但裝置上的可用空間不足(需要大小:{0} MB,可用空間:{1} MB)。",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "下載應用程式更新檔案失敗。",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "處理應用程式更新檔案失敗。",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "無法下載應用程式資源。 請在「設定」畫面中指定「應用程式 ID」。",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "找不到應用程式 '{0}'。 請先將其部署到 IBM MobileFirst Platform Server。",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "無法下載應用程式資源。 請在「設定」畫面中指定「應用程式版本」。",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "無法下載應用程式資源。 外觀:{0} 不存在。 請確定 getSkinName() 可解析為有效的外觀。",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "找不到 {2} 適用的應用程式 '{0}' {1}",
|
||||
"deviceAuthenticationFail" : "連線功能錯誤",
|
||||
"saveCertificateFailure" : "無法儲存憑證",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "目前無法連線至伺服器。 無法下載應用程式資源。",
|
||||
"expandWindow" : "展開應用程式加以使用",
|
||||
"exit" : "結束",
|
||||
"exitApplication" : "結束應用程式",
|
||||
"error" : "錯誤",
|
||||
"gadgetUpdateAvailable" : "有可用的應用程式更新",
|
||||
"getNewVersion" : "取得新版本",
|
||||
"handleTimeOut" : "{0} 的要求逾時。 請確定應用程式(特別是 Android 與 iPhone 應用程式)可使用該主機位址。",
|
||||
"invalidUsernamePassword" : "無效的使用者名稱或密碼",
|
||||
"keepAliveInBackgroundText" : "應用程式繼續在背景中執行",
|
||||
"loading" : "載入中",
|
||||
"login" : "登入",
|
||||
"minimize" : "最小化",
|
||||
"missingFeatureException" : "應用程式中缺少 {0},所以無法呼叫 {1}。 請在應用程式描述子中新增 {0},然後再行重建及部署。",
|
||||
"name" : "名稱:",
|
||||
"noInternet" : "無法連線至服務。",
|
||||
"notificationTitle" : "服務通知",
|
||||
"notAvailable" : "無法使用",
|
||||
"ok" : "確定",
|
||||
"password" : "密碼:",
|
||||
"reload" : "重新載入",
|
||||
"restore" : "還原",
|
||||
"requestTimeout" : "應用程式無法連線至服務。",
|
||||
"responseNotRecognized" : "非預期的回應。",
|
||||
"settings" : "設定",
|
||||
"serverError" : "程序呼叫錯誤。",
|
||||
"tryAgain" : "重試",
|
||||
"userInstanceAccessViolationException" : "嘗試登入不是為您登錄的應用程式。",
|
||||
"unexpectedError" : "伺服器無法處理應用程式的要求。請稍後再試一次。",
|
||||
"unresponsiveHost" : "服務目前無法使用。",
|
||||
"update" : "更新",
|
||||
"upgrade" : "升級",
|
||||
"upgradeGadget" : "您的應用程式版本為 {0}。此應用程式已有版本 {1} 可供使用。請按一下「確定」予以下載及安裝。",
|
||||
"wlclientInitFailure" : "錯誤",
|
||||
"wlSettings" : "IBM MobileFirst Platform 設定",
|
||||
"userEnrollmentUnsupportedOS" : "使用者憑證鑑別失敗:不受支援的用戶端平台。",
|
||||
"failureCallingMethod" : "呼叫 {0} 失敗",
|
||||
"challengeHandlingCanceled" : "已取消盤查處理程式作業。",
|
||||
"unsupportedEnvironment" : "不支援的環境",
|
||||
"redirect" : "重新導向"
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"IBM-INTERNAL" : "PII user facing" ,
|
||||
"accessDenied" : "拒绝访问",
|
||||
"authFailure" : "处理应用程序请求时遇到错误。",
|
||||
"applicationDenied" : "已禁用应用程序",
|
||||
"browserIsNotSupported" : "当前不支持 {0}。",
|
||||
"cancel" : "取消",
|
||||
"close" : "关闭",
|
||||
"cookiesAreDisabled" : "浏览器当前禁用 Cookie。 要使应用程序正常运行,必须启用 Cookie。",
|
||||
"copyToClipboard" : "复制",
|
||||
"details" : "详细信息",
|
||||
"diagApp" : "应用程序诊断",
|
||||
"diagTime" : "时间",
|
||||
"diagApplicationName" : "应用程序名称",
|
||||
"diagApplicationVersion" : "应用程序版本",
|
||||
"diagServiceURL" : "服务 URL",
|
||||
"diagDevicePlatform" : "设备平台",
|
||||
"diagDeviceVersion" : "设备版本",
|
||||
"diagScreenResolution" : "屏幕分辨率",
|
||||
"diagAirplaneMode" : "飞行模式",
|
||||
"diagUsingNetwork" : "使用网络",
|
||||
"diagWifiName" : "WiFi 名称",
|
||||
"diagMobileNetworkType" : "移动网络类型",
|
||||
"diagCarrierName" : "运营商名称",
|
||||
"diagErrorCode" : "错误代码",
|
||||
"diagErrorMessage" : "错误消息",
|
||||
"diagHttpStatus" : "HTTP 状态",
|
||||
"diagIPAddress" : "IP 地址",
|
||||
"directUpdateNotificationTitle" : "可用更新",
|
||||
"directUpdateNotificationMessage" : "有新的 Web 资源可用,确认更新。(文件大小为 {0} MB)。",
|
||||
"directUpdateNotificationMessageKilobytes" : "有新的 Web 资源可用,确认更新。(文件大小为 {0} KB)。",
|
||||
"directUpdateErrorTitle" : "更新失败",
|
||||
"directUpdateErrorMessage" : "直接更新失败。",
|
||||
"directUpdateErrorMessageNotEnoughStorage" : "该应用程序有一个可用更新,但设备空间不足(所需大小:{0} MB,可用空间:{1} MB)。",
|
||||
"directUpdateErrorMessageFailedDownloadingZipFile" : "下载应用程序更新文件失败。",
|
||||
"directUpdateErrorMessageFailedProcessingZipFile" : "处理应用程序更新文件失败。",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppID" : "无法下载应用程序资源。 请在“设置”屏幕上指定应用程序标识。",
|
||||
"downloadAppWebResourcesAppIdNotExist" : "找不到应用程序“{0}”。 请先将该应用程序部署到 IBM MobileFirst Platform 服务器。",
|
||||
"downloadAppWebResourcesPleaseSpecifyAppVersion" : "无法下载应用程序资源。 请在“设置”屏幕上指定应用程序版本。",
|
||||
"downloadAppWebResourcesSkinIsNotValid" : "无法下载应用程序资源。 外表:{0} 不存在。 请确保 getSkinName() 解析为有效外表。",
|
||||
"downloadAppWebResourcesAppVersionNotExist" : "无法为 {2} 找到应用程序“{0}”{1}",
|
||||
"deviceAuthenticationFail" : "连接错误",
|
||||
"saveCertificateFailure" : "无法保存证书",
|
||||
"downloadAppWebResourcesConnectionToServerUnavailable" : "无法连接至服务器。 无法下载应用程序资源。",
|
||||
"expandWindow" : "扩展应用程序以使用它",
|
||||
"exit" : "退出",
|
||||
"exitApplication" : "退出应用程序",
|
||||
"error" : "错误",
|
||||
"gadgetUpdateAvailable" : "应用程序更新可用",
|
||||
"getNewVersion" : "获取新版本",
|
||||
"handleTimeOut" : "对 {0} 的请求超时。 请确保应用程序可以使用该主机地址(尤其适用于 Android 和 iPhone 应用程序)。",
|
||||
"invalidUsernamePassword" : "无效的用户名或密码",
|
||||
"keepAliveInBackgroundText" : "应用程序一直在后台运行",
|
||||
"loading" : "正在装入",
|
||||
"login" : "登录",
|
||||
"minimize" : "最小化",
|
||||
"missingFeatureException" : "由于应用程序缺少 {0},因此调用 {1} 失败。 请将 {0} 添加至应用程序描述符,然后将其重新构建并部署。",
|
||||
"name" : "名称:",
|
||||
"noInternet" : "服务连接不可用。",
|
||||
"notificationTitle" : "服务通知",
|
||||
"notAvailable" : "不可用",
|
||||
"ok" : "确定",
|
||||
"password" : "密码:",
|
||||
"reload" : "重新装入",
|
||||
"restore" : "复原",
|
||||
"requestTimeout" : "应用程序无法连接至服务。",
|
||||
"responseNotRecognized" : "意外响应。",
|
||||
"settings" : "设置",
|
||||
"serverError" : "过程调用错误。",
|
||||
"tryAgain" : "请重试",
|
||||
"userInstanceAccessViolationException" : "您正在尝试登录到自己尚未注册的应用程序。",
|
||||
"unexpectedError" : "服务器无法处理该应用程序的请求。请稍后重试。",
|
||||
"unresponsiveHost" : "服务当前不可用。",
|
||||
"update" : "更新",
|
||||
"upgrade" : "升级",
|
||||
"upgradeGadget" : "您的应用程序版本为 {0}。该应用程序的 V{1} 可用。请单击“确定”以下载并安装该版本。",
|
||||
"wlclientInitFailure" : "错误",
|
||||
"wlSettings" : "IBM MobileFirst Platform 设置",
|
||||
"userEnrollmentUnsupportedOS" : "用户证书认证失败:不受支持的客户机平台。",
|
||||
"failureCallingMethod" : "调用 {0} 失败",
|
||||
"challengeHandlingCanceled" : "验证问题处理程序操作已取消。",
|
||||
"unsupportedEnvironment" : "不支持的环境",
|
||||
"redirect" : "重定向"
|
||||
}
|
||||
|
||||
_platforms/browser/platform_www/plugins/cordova-plugin-mfp/worklight/node_modules/express/History.md
Generated
Vendored
+3477
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
Copyright (c) 2013-2014 Roman Shtylman <shtylman+expressjs@gmail.com>
|
||||
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
Generated
Vendored
+155
@@ -0,0 +1,155 @@
|
||||
[](http://expressjs.com/)
|
||||
|
||||
Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Linux Build][travis-image]][travis-url]
|
||||
[![Windows Build][appveyor-image]][appveyor-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
```js
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('Hello World')
|
||||
})
|
||||
|
||||
app.listen(3000)
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/).
|
||||
|
||||
Before installing, [download and install Node.js](https://nodejs.org/en/download/).
|
||||
Node.js 0.10 or higher is required.
|
||||
|
||||
Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```bash
|
||||
$ npm install express
|
||||
```
|
||||
|
||||
Follow [our installing guide](http://expressjs.com/en/starter/installing.html)
|
||||
for more information.
|
||||
|
||||
## Features
|
||||
|
||||
* Robust routing
|
||||
* Focus on high performance
|
||||
* Super-high test coverage
|
||||
* HTTP helpers (redirection, caching, etc)
|
||||
* View system supporting 14+ template engines
|
||||
* Content negotiation
|
||||
* Executable for generating applications quickly
|
||||
|
||||
## Docs & Community
|
||||
|
||||
* [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)]
|
||||
* [#express](https://webchat.freenode.net/?channels=express) on freenode IRC
|
||||
* [GitHub Organization](https://github.com/expressjs) for Official Middleware & Modules
|
||||
* Visit the [Wiki](https://github.com/expressjs/express/wiki)
|
||||
* [Google Group](https://groups.google.com/group/express-js) for discussion
|
||||
* [Gitter](https://gitter.im/expressjs/express) for support and discussion
|
||||
|
||||
**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x).
|
||||
|
||||
### Security Issues
|
||||
|
||||
If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md).
|
||||
|
||||
## Quick Start
|
||||
|
||||
The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below:
|
||||
|
||||
Install the executable. The executable's major version will match Express's:
|
||||
|
||||
```bash
|
||||
$ npm install -g express-generator@4
|
||||
```
|
||||
|
||||
Create the app:
|
||||
|
||||
```bash
|
||||
$ express /tmp/foo && cd /tmp/foo
|
||||
```
|
||||
|
||||
Install dependencies:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Start the server:
|
||||
|
||||
```bash
|
||||
$ npm start
|
||||
```
|
||||
|
||||
View the website at: http://localhost:3000
|
||||
|
||||
## Philosophy
|
||||
|
||||
The Express philosophy is to provide small, robust tooling for HTTP servers, making
|
||||
it a great solution for single page applications, web sites, hybrids, or public
|
||||
HTTP APIs.
|
||||
|
||||
Express does not force you to use any specific ORM or template engine. With support for over
|
||||
14 template engines via [Consolidate.js](https://github.com/tj/consolidate.js),
|
||||
you can quickly craft your perfect framework.
|
||||
|
||||
## Examples
|
||||
|
||||
To view the examples, clone the Express repo and install the dependencies:
|
||||
|
||||
```bash
|
||||
$ git clone git://github.com/expressjs/express.git --depth 1
|
||||
$ cd express
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Then run whichever example you want:
|
||||
|
||||
```bash
|
||||
$ node examples/content-negotiation
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
To run the test suite, first install the dependencies, then run `npm test`:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
[Contributing Guide](Contributing.md)
|
||||
|
||||
## People
|
||||
|
||||
The original author of Express is [TJ Holowaychuk](https://github.com/tj)
|
||||
|
||||
The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson)
|
||||
|
||||
[List of all contributors](https://github.com/expressjs/express/graphs/contributors)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/express.svg
|
||||
[npm-url]: https://npmjs.org/package/express
|
||||
[downloads-image]: https://img.shields.io/npm/dm/express.svg
|
||||
[downloads-url]: https://npmjs.org/package/express
|
||||
[travis-image]: https://img.shields.io/travis/expressjs/express/master.svg?label=linux
|
||||
[travis-url]: https://travis-ci.org/expressjs/express
|
||||
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/express/master.svg?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express
|
||||
[coveralls-image]: https://img.shields.io/coveralls/expressjs/express/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./lib/express');
|
||||
Generated
Vendored
+644
@@ -0,0 +1,644 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var finalhandler = require('finalhandler');
|
||||
var Router = require('./router');
|
||||
var methods = require('methods');
|
||||
var middleware = require('./middleware/init');
|
||||
var query = require('./middleware/query');
|
||||
var debug = require('debug')('express:application');
|
||||
var View = require('./view');
|
||||
var http = require('http');
|
||||
var compileETag = require('./utils').compileETag;
|
||||
var compileQueryParser = require('./utils').compileQueryParser;
|
||||
var compileTrust = require('./utils').compileTrust;
|
||||
var deprecate = require('depd')('express');
|
||||
var flatten = require('array-flatten');
|
||||
var merge = require('utils-merge');
|
||||
var resolve = require('path').resolve;
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
var slice = Array.prototype.slice;
|
||||
|
||||
/**
|
||||
* Application prototype.
|
||||
*/
|
||||
|
||||
var app = exports = module.exports = {};
|
||||
|
||||
/**
|
||||
* Variable for trust proxy inheritance back-compat
|
||||
* @private
|
||||
*/
|
||||
|
||||
var trustProxyDefaultSymbol = '@@symbol:trust_proxy_default';
|
||||
|
||||
/**
|
||||
* Initialize the server.
|
||||
*
|
||||
* - setup default configuration
|
||||
* - setup default middleware
|
||||
* - setup route reflection methods
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
app.init = function init() {
|
||||
this.cache = {};
|
||||
this.engines = {};
|
||||
this.settings = {};
|
||||
|
||||
this.defaultConfiguration();
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize application configuration.
|
||||
* @private
|
||||
*/
|
||||
|
||||
app.defaultConfiguration = function defaultConfiguration() {
|
||||
var env = process.env.NODE_ENV || 'development';
|
||||
|
||||
// default settings
|
||||
this.enable('x-powered-by');
|
||||
this.set('etag', 'weak');
|
||||
this.set('env', env);
|
||||
this.set('query parser', 'extended');
|
||||
this.set('subdomain offset', 2);
|
||||
this.set('trust proxy', false);
|
||||
|
||||
// trust proxy inherit back-compat
|
||||
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
|
||||
configurable: true,
|
||||
value: true
|
||||
});
|
||||
|
||||
debug('booting in %s mode', env);
|
||||
|
||||
this.on('mount', function onmount(parent) {
|
||||
// inherit trust proxy
|
||||
if (this.settings[trustProxyDefaultSymbol] === true
|
||||
&& typeof parent.settings['trust proxy fn'] === 'function') {
|
||||
delete this.settings['trust proxy'];
|
||||
delete this.settings['trust proxy fn'];
|
||||
}
|
||||
|
||||
// inherit protos
|
||||
setPrototypeOf(this.request, parent.request)
|
||||
setPrototypeOf(this.response, parent.response)
|
||||
setPrototypeOf(this.engines, parent.engines)
|
||||
setPrototypeOf(this.settings, parent.settings)
|
||||
});
|
||||
|
||||
// setup locals
|
||||
this.locals = Object.create(null);
|
||||
|
||||
// top-most app is mounted at /
|
||||
this.mountpath = '/';
|
||||
|
||||
// default locals
|
||||
this.locals.settings = this.settings;
|
||||
|
||||
// default configuration
|
||||
this.set('view', View);
|
||||
this.set('views', resolve('views'));
|
||||
this.set('jsonp callback name', 'callback');
|
||||
|
||||
if (env === 'production') {
|
||||
this.enable('view cache');
|
||||
}
|
||||
|
||||
Object.defineProperty(this, 'router', {
|
||||
get: function() {
|
||||
throw new Error('\'app.router\' is deprecated!\nPlease see the 3.x to 4.x migration guide for details on how to update your app.');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* lazily adds the base router if it has not yet been added.
|
||||
*
|
||||
* We cannot add the base router in the defaultConfiguration because
|
||||
* it reads app settings which might be set after that has run.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
app.lazyrouter = function lazyrouter() {
|
||||
if (!this._router) {
|
||||
this._router = new Router({
|
||||
caseSensitive: this.enabled('case sensitive routing'),
|
||||
strict: this.enabled('strict routing')
|
||||
});
|
||||
|
||||
this._router.use(query(this.get('query parser fn')));
|
||||
this._router.use(middleware.init(this));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispatch a req, res pair into the application. Starts pipeline processing.
|
||||
*
|
||||
* If no callback is provided, then default error handlers will respond
|
||||
* in the event of an error bubbling through the stack.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
|
||||
app.handle = function handle(req, res, callback) {
|
||||
var router = this._router;
|
||||
|
||||
// final handler
|
||||
var done = callback || finalhandler(req, res, {
|
||||
env: this.get('env'),
|
||||
onerror: logerror.bind(this)
|
||||
});
|
||||
|
||||
// no routes
|
||||
if (!router) {
|
||||
debug('no routes defined on app');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
router.handle(req, res, done);
|
||||
};
|
||||
|
||||
/**
|
||||
* Proxy `Router#use()` to add middleware to the app router.
|
||||
* See Router#use() documentation for details.
|
||||
*
|
||||
* If the _fn_ parameter is an express app, then it will be
|
||||
* mounted at the _route_ specified.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.use = function use(fn) {
|
||||
var offset = 0;
|
||||
var path = '/';
|
||||
|
||||
// default path to '/'
|
||||
// disambiguate app.use([fn])
|
||||
if (typeof fn !== 'function') {
|
||||
var arg = fn;
|
||||
|
||||
while (Array.isArray(arg) && arg.length !== 0) {
|
||||
arg = arg[0];
|
||||
}
|
||||
|
||||
// first arg is the path
|
||||
if (typeof arg !== 'function') {
|
||||
offset = 1;
|
||||
path = fn;
|
||||
}
|
||||
}
|
||||
|
||||
var fns = flatten(slice.call(arguments, offset));
|
||||
|
||||
if (fns.length === 0) {
|
||||
throw new TypeError('app.use() requires a middleware function')
|
||||
}
|
||||
|
||||
// setup router
|
||||
this.lazyrouter();
|
||||
var router = this._router;
|
||||
|
||||
fns.forEach(function (fn) {
|
||||
// non-express app
|
||||
if (!fn || !fn.handle || !fn.set) {
|
||||
return router.use(path, fn);
|
||||
}
|
||||
|
||||
debug('.use app under %s', path);
|
||||
fn.mountpath = path;
|
||||
fn.parent = this;
|
||||
|
||||
// restore .app property on req and res
|
||||
router.use(path, function mounted_app(req, res, next) {
|
||||
var orig = req.app;
|
||||
fn.handle(req, res, function (err) {
|
||||
setPrototypeOf(req, orig.request)
|
||||
setPrototypeOf(res, orig.response)
|
||||
next(err);
|
||||
});
|
||||
});
|
||||
|
||||
// mounted an app
|
||||
fn.emit('mount', this);
|
||||
}, this);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Proxy to the app `Router#route()`
|
||||
* Returns a new `Route` instance for the _path_.
|
||||
*
|
||||
* Routes are isolated middleware stacks for specific paths.
|
||||
* See the Route api docs for details.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.route = function route(path) {
|
||||
this.lazyrouter();
|
||||
return this._router.route(path);
|
||||
};
|
||||
|
||||
/**
|
||||
* Register the given template engine callback `fn`
|
||||
* as `ext`.
|
||||
*
|
||||
* By default will `require()` the engine based on the
|
||||
* file extension. For example if you try to render
|
||||
* a "foo.ejs" file Express will invoke the following internally:
|
||||
*
|
||||
* app.engine('ejs', require('ejs').__express);
|
||||
*
|
||||
* For engines that do not provide `.__express` out of the box,
|
||||
* or if you wish to "map" a different extension to the template engine
|
||||
* you may use this method. For example mapping the EJS template engine to
|
||||
* ".html" files:
|
||||
*
|
||||
* app.engine('html', require('ejs').renderFile);
|
||||
*
|
||||
* In this case EJS provides a `.renderFile()` method with
|
||||
* the same signature that Express expects: `(path, options, callback)`,
|
||||
* though note that it aliases this method as `ejs.__express` internally
|
||||
* so if you're using ".ejs" extensions you dont need to do anything.
|
||||
*
|
||||
* Some template engines do not follow this convention, the
|
||||
* [Consolidate.js](https://github.com/tj/consolidate.js)
|
||||
* library was created to map all of node's popular template
|
||||
* engines to follow this convention, thus allowing them to
|
||||
* work seamlessly within Express.
|
||||
*
|
||||
* @param {String} ext
|
||||
* @param {Function} fn
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.engine = function engine(ext, fn) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new Error('callback function required');
|
||||
}
|
||||
|
||||
// get file extension
|
||||
var extension = ext[0] !== '.'
|
||||
? '.' + ext
|
||||
: ext;
|
||||
|
||||
// store engine
|
||||
this.engines[extension] = fn;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Proxy to `Router#param()` with one added api feature. The _name_ parameter
|
||||
* can be an array of names.
|
||||
*
|
||||
* See the Router#param() docs for more details.
|
||||
*
|
||||
* @param {String|Array} name
|
||||
* @param {Function} fn
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.param = function param(name, fn) {
|
||||
this.lazyrouter();
|
||||
|
||||
if (Array.isArray(name)) {
|
||||
for (var i = 0; i < name.length; i++) {
|
||||
this.param(name[i], fn);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
this._router.param(name, fn);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Assign `setting` to `val`, or return `setting`'s value.
|
||||
*
|
||||
* app.set('foo', 'bar');
|
||||
* app.set('foo');
|
||||
* // => "bar"
|
||||
*
|
||||
* Mounted servers inherit their parent server's settings.
|
||||
*
|
||||
* @param {String} setting
|
||||
* @param {*} [val]
|
||||
* @return {Server} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.set = function set(setting, val) {
|
||||
if (arguments.length === 1) {
|
||||
// app.get(setting)
|
||||
return this.settings[setting];
|
||||
}
|
||||
|
||||
debug('set "%s" to %o', setting, val);
|
||||
|
||||
// set value
|
||||
this.settings[setting] = val;
|
||||
|
||||
// trigger matched settings
|
||||
switch (setting) {
|
||||
case 'etag':
|
||||
this.set('etag fn', compileETag(val));
|
||||
break;
|
||||
case 'query parser':
|
||||
this.set('query parser fn', compileQueryParser(val));
|
||||
break;
|
||||
case 'trust proxy':
|
||||
this.set('trust proxy fn', compileTrust(val));
|
||||
|
||||
// trust proxy inherit back-compat
|
||||
Object.defineProperty(this.settings, trustProxyDefaultSymbol, {
|
||||
configurable: true,
|
||||
value: false
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the app's absolute pathname
|
||||
* based on the parent(s) that have
|
||||
* mounted it.
|
||||
*
|
||||
* For example if the application was
|
||||
* mounted as "/admin", which itself
|
||||
* was mounted as "/blog" then the
|
||||
* return value would be "/blog/admin".
|
||||
*
|
||||
* @return {String}
|
||||
* @private
|
||||
*/
|
||||
|
||||
app.path = function path() {
|
||||
return this.parent
|
||||
? this.parent.path() + this.mountpath
|
||||
: '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if `setting` is enabled (truthy).
|
||||
*
|
||||
* app.enabled('foo')
|
||||
* // => false
|
||||
*
|
||||
* app.enable('foo')
|
||||
* app.enabled('foo')
|
||||
* // => true
|
||||
*
|
||||
* @param {String} setting
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.enabled = function enabled(setting) {
|
||||
return Boolean(this.set(setting));
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if `setting` is disabled.
|
||||
*
|
||||
* app.disabled('foo')
|
||||
* // => true
|
||||
*
|
||||
* app.enable('foo')
|
||||
* app.disabled('foo')
|
||||
* // => false
|
||||
*
|
||||
* @param {String} setting
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.disabled = function disabled(setting) {
|
||||
return !this.set(setting);
|
||||
};
|
||||
|
||||
/**
|
||||
* Enable `setting`.
|
||||
*
|
||||
* @param {String} setting
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.enable = function enable(setting) {
|
||||
return this.set(setting, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Disable `setting`.
|
||||
*
|
||||
* @param {String} setting
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.disable = function disable(setting) {
|
||||
return this.set(setting, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Delegate `.VERB(...)` calls to `router.VERB(...)`.
|
||||
*/
|
||||
|
||||
methods.forEach(function(method){
|
||||
app[method] = function(path){
|
||||
if (method === 'get' && arguments.length === 1) {
|
||||
// app.get(setting)
|
||||
return this.set(path);
|
||||
}
|
||||
|
||||
this.lazyrouter();
|
||||
|
||||
var route = this._router.route(path);
|
||||
route[method].apply(route, slice.call(arguments, 1));
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Special-cased "all" method, applying the given route `path`,
|
||||
* middleware, and callback to _every_ HTTP method.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Function} ...
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.all = function all(path) {
|
||||
this.lazyrouter();
|
||||
|
||||
var route = this._router.route(path);
|
||||
var args = slice.call(arguments, 1);
|
||||
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
route[methods[i]].apply(route, args);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// del -> delete alias
|
||||
|
||||
app.del = deprecate.function(app.delete, 'app.del: Use app.delete instead');
|
||||
|
||||
/**
|
||||
* Render the given view `name` name with `options`
|
||||
* and a callback accepting an error and the
|
||||
* rendered template string.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* app.render('email', { name: 'Tobi' }, function(err, html){
|
||||
* // ...
|
||||
* })
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Object|Function} options or fn
|
||||
* @param {Function} callback
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.render = function render(name, options, callback) {
|
||||
var cache = this.cache;
|
||||
var done = callback;
|
||||
var engines = this.engines;
|
||||
var opts = options;
|
||||
var renderOptions = {};
|
||||
var view;
|
||||
|
||||
// support callback function as second arg
|
||||
if (typeof options === 'function') {
|
||||
done = options;
|
||||
opts = {};
|
||||
}
|
||||
|
||||
// merge app.locals
|
||||
merge(renderOptions, this.locals);
|
||||
|
||||
// merge options._locals
|
||||
if (opts._locals) {
|
||||
merge(renderOptions, opts._locals);
|
||||
}
|
||||
|
||||
// merge options
|
||||
merge(renderOptions, opts);
|
||||
|
||||
// set .cache unless explicitly provided
|
||||
if (renderOptions.cache == null) {
|
||||
renderOptions.cache = this.enabled('view cache');
|
||||
}
|
||||
|
||||
// primed cache
|
||||
if (renderOptions.cache) {
|
||||
view = cache[name];
|
||||
}
|
||||
|
||||
// view
|
||||
if (!view) {
|
||||
var View = this.get('view');
|
||||
|
||||
view = new View(name, {
|
||||
defaultEngine: this.get('view engine'),
|
||||
root: this.get('views'),
|
||||
engines: engines
|
||||
});
|
||||
|
||||
if (!view.path) {
|
||||
var dirs = Array.isArray(view.root) && view.root.length > 1
|
||||
? 'directories "' + view.root.slice(0, -1).join('", "') + '" or "' + view.root[view.root.length - 1] + '"'
|
||||
: 'directory "' + view.root + '"'
|
||||
var err = new Error('Failed to lookup view "' + name + '" in views ' + dirs);
|
||||
err.view = view;
|
||||
return done(err);
|
||||
}
|
||||
|
||||
// prime the cache
|
||||
if (renderOptions.cache) {
|
||||
cache[name] = view;
|
||||
}
|
||||
}
|
||||
|
||||
// render
|
||||
tryRender(view, renderOptions, done);
|
||||
};
|
||||
|
||||
/**
|
||||
* Listen for connections.
|
||||
*
|
||||
* A node `http.Server` is returned, with this
|
||||
* application (which is a `Function`) as its
|
||||
* callback. If you wish to create both an HTTP
|
||||
* and HTTPS server you may do so with the "http"
|
||||
* and "https" modules as shown here:
|
||||
*
|
||||
* var http = require('http')
|
||||
* , https = require('https')
|
||||
* , express = require('express')
|
||||
* , app = express();
|
||||
*
|
||||
* http.createServer(app).listen(80);
|
||||
* https.createServer({ ... }, app).listen(443);
|
||||
*
|
||||
* @return {http.Server}
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.listen = function listen() {
|
||||
var server = http.createServer(this);
|
||||
return server.listen.apply(server, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Log error using console.error.
|
||||
*
|
||||
* @param {Error} err
|
||||
* @private
|
||||
*/
|
||||
|
||||
function logerror(err) {
|
||||
/* istanbul ignore next */
|
||||
if (this.get('env') !== 'test') console.error(err.stack || err.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Try rendering a view.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function tryRender(view, options, callback) {
|
||||
try {
|
||||
view.render(options, callback);
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+116
@@ -0,0 +1,116 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var bodyParser = require('body-parser')
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var mixin = require('merge-descriptors');
|
||||
var proto = require('./application');
|
||||
var Route = require('./router/route');
|
||||
var Router = require('./router');
|
||||
var req = require('./request');
|
||||
var res = require('./response');
|
||||
|
||||
/**
|
||||
* Expose `createApplication()`.
|
||||
*/
|
||||
|
||||
exports = module.exports = createApplication;
|
||||
|
||||
/**
|
||||
* Create an express application.
|
||||
*
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function createApplication() {
|
||||
var app = function(req, res, next) {
|
||||
app.handle(req, res, next);
|
||||
};
|
||||
|
||||
mixin(app, EventEmitter.prototype, false);
|
||||
mixin(app, proto, false);
|
||||
|
||||
// expose the prototype that will get set on requests
|
||||
app.request = Object.create(req, {
|
||||
app: { configurable: true, enumerable: true, writable: true, value: app }
|
||||
})
|
||||
|
||||
// expose the prototype that will get set on responses
|
||||
app.response = Object.create(res, {
|
||||
app: { configurable: true, enumerable: true, writable: true, value: app }
|
||||
})
|
||||
|
||||
app.init();
|
||||
return app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose the prototypes.
|
||||
*/
|
||||
|
||||
exports.application = proto;
|
||||
exports.request = req;
|
||||
exports.response = res;
|
||||
|
||||
/**
|
||||
* Expose constructors.
|
||||
*/
|
||||
|
||||
exports.Route = Route;
|
||||
exports.Router = Router;
|
||||
|
||||
/**
|
||||
* Expose middleware
|
||||
*/
|
||||
|
||||
exports.json = bodyParser.json
|
||||
exports.query = require('./middleware/query');
|
||||
exports.raw = bodyParser.raw
|
||||
exports.static = require('serve-static');
|
||||
exports.text = bodyParser.text
|
||||
exports.urlencoded = bodyParser.urlencoded
|
||||
|
||||
/**
|
||||
* Replace removed middleware with an appropriate error message.
|
||||
*/
|
||||
|
||||
var removedMiddlewares = [
|
||||
'bodyParser',
|
||||
'compress',
|
||||
'cookieSession',
|
||||
'session',
|
||||
'logger',
|
||||
'cookieParser',
|
||||
'favicon',
|
||||
'responseTime',
|
||||
'errorHandler',
|
||||
'timeout',
|
||||
'methodOverride',
|
||||
'vhost',
|
||||
'csrf',
|
||||
'directory',
|
||||
'limit',
|
||||
'multipart',
|
||||
'staticCache'
|
||||
]
|
||||
|
||||
removedMiddlewares.forEach(function (name) {
|
||||
Object.defineProperty(exports, name, {
|
||||
get: function () {
|
||||
throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
});
|
||||
Generated
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
|
||||
/**
|
||||
* Initialization middleware, exposing the
|
||||
* request and response to each other, as well
|
||||
* as defaulting the X-Powered-By header field.
|
||||
*
|
||||
* @param {Function} app
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.init = function(app){
|
||||
return function expressInit(req, res, next){
|
||||
if (app.enabled('x-powered-by')) res.setHeader('X-Powered-By', 'Express');
|
||||
req.res = res;
|
||||
res.req = req;
|
||||
req.next = next;
|
||||
|
||||
setPrototypeOf(req, app.request)
|
||||
setPrototypeOf(res, app.response)
|
||||
|
||||
res.locals = res.locals || Object.create(null);
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
|
||||
Generated
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var merge = require('utils-merge')
|
||||
var parseUrl = require('parseurl');
|
||||
var qs = require('qs');
|
||||
|
||||
/**
|
||||
* @param {Object} options
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function query(options) {
|
||||
var opts = merge({}, options)
|
||||
var queryparse = qs.parse;
|
||||
|
||||
if (typeof options === 'function') {
|
||||
queryparse = options;
|
||||
opts = undefined;
|
||||
}
|
||||
|
||||
if (opts !== undefined && opts.allowPrototypes === undefined) {
|
||||
// back-compat for qs module
|
||||
opts.allowPrototypes = true;
|
||||
}
|
||||
|
||||
return function query(req, res, next){
|
||||
if (!req.query) {
|
||||
var val = parseUrl(req).query;
|
||||
req.query = queryparse(val, opts);
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
Generated
Vendored
+525
@@ -0,0 +1,525 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var accepts = require('accepts');
|
||||
var deprecate = require('depd')('express');
|
||||
var isIP = require('net').isIP;
|
||||
var typeis = require('type-is');
|
||||
var http = require('http');
|
||||
var fresh = require('fresh');
|
||||
var parseRange = require('range-parser');
|
||||
var parse = require('parseurl');
|
||||
var proxyaddr = require('proxy-addr');
|
||||
|
||||
/**
|
||||
* Request prototype.
|
||||
* @public
|
||||
*/
|
||||
|
||||
var req = Object.create(http.IncomingMessage.prototype)
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = req
|
||||
|
||||
/**
|
||||
* Return request header.
|
||||
*
|
||||
* The `Referrer` header field is special-cased,
|
||||
* both `Referrer` and `Referer` are interchangeable.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* req.get('Content-Type');
|
||||
* // => "text/plain"
|
||||
*
|
||||
* req.get('content-type');
|
||||
* // => "text/plain"
|
||||
*
|
||||
* req.get('Something');
|
||||
* // => undefined
|
||||
*
|
||||
* Aliased as `req.header()`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.get =
|
||||
req.header = function header(name) {
|
||||
if (!name) {
|
||||
throw new TypeError('name argument is required to req.get');
|
||||
}
|
||||
|
||||
if (typeof name !== 'string') {
|
||||
throw new TypeError('name must be a string to req.get');
|
||||
}
|
||||
|
||||
var lc = name.toLowerCase();
|
||||
|
||||
switch (lc) {
|
||||
case 'referer':
|
||||
case 'referrer':
|
||||
return this.headers.referrer
|
||||
|| this.headers.referer;
|
||||
default:
|
||||
return this.headers[lc];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* To do: update docs.
|
||||
*
|
||||
* Check if the given `type(s)` is acceptable, returning
|
||||
* the best match when true, otherwise `undefined`, in which
|
||||
* case you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* The `type` value may be a single MIME type string
|
||||
* such as "application/json", an extension name
|
||||
* such as "json", a comma-delimited list such as "json, html, text/plain",
|
||||
* an argument list such as `"json", "html", "text/plain"`,
|
||||
* or an array `["json", "html", "text/plain"]`. When a list
|
||||
* or array is given, the _best_ match, if any is returned.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // Accept: text/html
|
||||
* req.accepts('html');
|
||||
* // => "html"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* req.accepts('html');
|
||||
* // => "html"
|
||||
* req.accepts('text/html');
|
||||
* // => "text/html"
|
||||
* req.accepts('json, text');
|
||||
* // => "json"
|
||||
* req.accepts('application/json');
|
||||
* // => "application/json"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* req.accepts('image/png');
|
||||
* req.accepts('png');
|
||||
* // => undefined
|
||||
*
|
||||
* // Accept: text/*;q=.5, application/json
|
||||
* req.accepts(['html', 'json']);
|
||||
* req.accepts('html', 'json');
|
||||
* req.accepts('html, json');
|
||||
* // => "json"
|
||||
*
|
||||
* @param {String|Array} type(s)
|
||||
* @return {String|Array|Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.accepts = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.types.apply(accept, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the given `encoding`s are accepted.
|
||||
*
|
||||
* @param {String} ...encoding
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.acceptsEncodings = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.encodings.apply(accept, arguments);
|
||||
};
|
||||
|
||||
req.acceptsEncoding = deprecate.function(req.acceptsEncodings,
|
||||
'req.acceptsEncoding: Use acceptsEncodings instead');
|
||||
|
||||
/**
|
||||
* Check if the given `charset`s are acceptable,
|
||||
* otherwise you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* @param {String} ...charset
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.acceptsCharsets = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.charsets.apply(accept, arguments);
|
||||
};
|
||||
|
||||
req.acceptsCharset = deprecate.function(req.acceptsCharsets,
|
||||
'req.acceptsCharset: Use acceptsCharsets instead');
|
||||
|
||||
/**
|
||||
* Check if the given `lang`s are acceptable,
|
||||
* otherwise you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* @param {String} ...lang
|
||||
* @return {String|Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.acceptsLanguages = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.languages.apply(accept, arguments);
|
||||
};
|
||||
|
||||
req.acceptsLanguage = deprecate.function(req.acceptsLanguages,
|
||||
'req.acceptsLanguage: Use acceptsLanguages instead');
|
||||
|
||||
/**
|
||||
* Parse Range header field, capping to the given `size`.
|
||||
*
|
||||
* Unspecified ranges such as "0-" require knowledge of your resource length. In
|
||||
* the case of a byte range this is of course the total number of bytes. If the
|
||||
* Range header field is not given `undefined` is returned, `-1` when unsatisfiable,
|
||||
* and `-2` when syntactically invalid.
|
||||
*
|
||||
* When ranges are returned, the array has a "type" property which is the type of
|
||||
* range that is required (most commonly, "bytes"). Each array element is an object
|
||||
* with a "start" and "end" property for the portion of the range.
|
||||
*
|
||||
* The "combine" option can be set to `true` and overlapping & adjacent ranges
|
||||
* will be combined into a single range.
|
||||
*
|
||||
* NOTE: remember that ranges are inclusive, so for example "Range: users=0-3"
|
||||
* should respond with 4 users when available, not 3.
|
||||
*
|
||||
* @param {number} size
|
||||
* @param {object} [options]
|
||||
* @param {boolean} [options.combine=false]
|
||||
* @return {number|array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.range = function range(size, options) {
|
||||
var range = this.get('Range');
|
||||
if (!range) return;
|
||||
return parseRange(size, range, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the value of param `name` when present or `defaultValue`.
|
||||
*
|
||||
* - Checks route placeholders, ex: _/user/:id_
|
||||
* - Checks body params, ex: id=12, {"id":12}
|
||||
* - Checks query string params, ex: ?id=12
|
||||
*
|
||||
* To utilize request bodies, `req.body`
|
||||
* should be an object. This can be done by using
|
||||
* the `bodyParser()` middleware.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Mixed} [defaultValue]
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.param = function param(name, defaultValue) {
|
||||
var params = this.params || {};
|
||||
var body = this.body || {};
|
||||
var query = this.query || {};
|
||||
|
||||
var args = arguments.length === 1
|
||||
? 'name'
|
||||
: 'name, default';
|
||||
deprecate('req.param(' + args + '): Use req.params, req.body, or req.query instead');
|
||||
|
||||
if (null != params[name] && params.hasOwnProperty(name)) return params[name];
|
||||
if (null != body[name]) return body[name];
|
||||
if (null != query[name]) return query[name];
|
||||
|
||||
return defaultValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the incoming request contains the "Content-Type"
|
||||
* header field, and it contains the give mime `type`.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // With Content-Type: text/html; charset=utf-8
|
||||
* req.is('html');
|
||||
* req.is('text/html');
|
||||
* req.is('text/*');
|
||||
* // => true
|
||||
*
|
||||
* // When Content-Type is application/json
|
||||
* req.is('json');
|
||||
* req.is('application/json');
|
||||
* req.is('application/*');
|
||||
* // => true
|
||||
*
|
||||
* req.is('html');
|
||||
* // => false
|
||||
*
|
||||
* @param {String|Array} types...
|
||||
* @return {String|false|null}
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.is = function is(types) {
|
||||
var arr = types;
|
||||
|
||||
// support flattened arguments
|
||||
if (!Array.isArray(types)) {
|
||||
arr = new Array(arguments.length);
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
arr[i] = arguments[i];
|
||||
}
|
||||
}
|
||||
|
||||
return typeis(this, arr);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the protocol string "http" or "https"
|
||||
* when requested with TLS. When the "trust proxy"
|
||||
* setting trusts the socket address, the
|
||||
* "X-Forwarded-Proto" header field will be trusted
|
||||
* and used if present.
|
||||
*
|
||||
* If you're running behind a reverse proxy that
|
||||
* supplies https for you this may be enabled.
|
||||
*
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'protocol', function protocol(){
|
||||
var proto = this.connection.encrypted
|
||||
? 'https'
|
||||
: 'http';
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
|
||||
if (!trust(this.connection.remoteAddress, 0)) {
|
||||
return proto;
|
||||
}
|
||||
|
||||
// Note: X-Forwarded-Proto is normally only ever a
|
||||
// single value, but this is to be safe.
|
||||
var header = this.get('X-Forwarded-Proto') || proto
|
||||
var index = header.indexOf(',')
|
||||
|
||||
return index !== -1
|
||||
? header.substring(0, index).trim()
|
||||
: header.trim()
|
||||
});
|
||||
|
||||
/**
|
||||
* Short-hand for:
|
||||
*
|
||||
* req.protocol === 'https'
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'secure', function secure(){
|
||||
return this.protocol === 'https';
|
||||
});
|
||||
|
||||
/**
|
||||
* Return the remote address from the trusted proxy.
|
||||
*
|
||||
* The is the remote address on the socket unless
|
||||
* "trust proxy" is set.
|
||||
*
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'ip', function ip(){
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
return proxyaddr(this, trust);
|
||||
});
|
||||
|
||||
/**
|
||||
* When "trust proxy" is set, trusted proxy addresses + client.
|
||||
*
|
||||
* For example if the value were "client, proxy1, proxy2"
|
||||
* you would receive the array `["client", "proxy1", "proxy2"]`
|
||||
* where "proxy2" is the furthest down-stream and "proxy1" and
|
||||
* "proxy2" were trusted.
|
||||
*
|
||||
* @return {Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'ips', function ips() {
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
var addrs = proxyaddr.all(this, trust);
|
||||
|
||||
// reverse the order (to farthest -> closest)
|
||||
// and remove socket address
|
||||
addrs.reverse().pop()
|
||||
|
||||
return addrs
|
||||
});
|
||||
|
||||
/**
|
||||
* Return subdomains as an array.
|
||||
*
|
||||
* Subdomains are the dot-separated parts of the host before the main domain of
|
||||
* the app. By default, the domain of the app is assumed to be the last two
|
||||
* parts of the host. This can be changed by setting "subdomain offset".
|
||||
*
|
||||
* For example, if the domain is "tobi.ferrets.example.com":
|
||||
* If "subdomain offset" is not set, req.subdomains is `["ferrets", "tobi"]`.
|
||||
* If "subdomain offset" is 3, req.subdomains is `["tobi"]`.
|
||||
*
|
||||
* @return {Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'subdomains', function subdomains() {
|
||||
var hostname = this.hostname;
|
||||
|
||||
if (!hostname) return [];
|
||||
|
||||
var offset = this.app.get('subdomain offset');
|
||||
var subdomains = !isIP(hostname)
|
||||
? hostname.split('.').reverse()
|
||||
: [hostname];
|
||||
|
||||
return subdomains.slice(offset);
|
||||
});
|
||||
|
||||
/**
|
||||
* Short-hand for `url.parse(req.url).pathname`.
|
||||
*
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'path', function path() {
|
||||
return parse(this).pathname;
|
||||
});
|
||||
|
||||
/**
|
||||
* Parse the "Host" header field to a hostname.
|
||||
*
|
||||
* When the "trust proxy" setting trusts the socket
|
||||
* address, the "X-Forwarded-Host" header field will
|
||||
* be trusted.
|
||||
*
|
||||
* @return {String}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'hostname', function hostname(){
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
var host = this.get('X-Forwarded-Host');
|
||||
|
||||
if (!host || !trust(this.connection.remoteAddress, 0)) {
|
||||
host = this.get('Host');
|
||||
} else if (host.indexOf(',') !== -1) {
|
||||
// Note: X-Forwarded-Host is normally only ever a
|
||||
// single value, but this is to be safe.
|
||||
host = host.substring(0, host.indexOf(',')).trimRight()
|
||||
}
|
||||
|
||||
if (!host) return;
|
||||
|
||||
// IPv6 literal support
|
||||
var offset = host[0] === '['
|
||||
? host.indexOf(']') + 1
|
||||
: 0;
|
||||
var index = host.indexOf(':', offset);
|
||||
|
||||
return index !== -1
|
||||
? host.substring(0, index)
|
||||
: host;
|
||||
});
|
||||
|
||||
// TODO: change req.host to return host in next major
|
||||
|
||||
defineGetter(req, 'host', deprecate.function(function host(){
|
||||
return this.hostname;
|
||||
}, 'req.host: Use req.hostname instead'));
|
||||
|
||||
/**
|
||||
* Check if the request is fresh, aka
|
||||
* Last-Modified and/or the ETag
|
||||
* still match.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'fresh', function(){
|
||||
var method = this.method;
|
||||
var res = this.res
|
||||
var status = res.statusCode
|
||||
|
||||
// GET or HEAD for weak freshness validation only
|
||||
if ('GET' !== method && 'HEAD' !== method) return false;
|
||||
|
||||
// 2xx or 304 as per rfc2616 14.26
|
||||
if ((status >= 200 && status < 300) || 304 === status) {
|
||||
return fresh(this.headers, {
|
||||
'etag': res.get('ETag'),
|
||||
'last-modified': res.get('Last-Modified')
|
||||
})
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if the request is stale, aka
|
||||
* "Last-Modified" and / or the "ETag" for the
|
||||
* resource has changed.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'stale', function stale(){
|
||||
return !this.fresh;
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if the request was an _XMLHttpRequest_.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
defineGetter(req, 'xhr', function xhr(){
|
||||
var val = this.get('X-Requested-With') || '';
|
||||
return val.toLowerCase() === 'xmlhttprequest';
|
||||
});
|
||||
|
||||
/**
|
||||
* Helper function for creating a getter on an object.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {String} name
|
||||
* @param {Function} getter
|
||||
* @private
|
||||
*/
|
||||
function defineGetter(obj, name, getter) {
|
||||
Object.defineProperty(obj, name, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: getter
|
||||
});
|
||||
}
|
||||
Generated
Vendored
+1142
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+662
@@ -0,0 +1,662 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var Route = require('./route');
|
||||
var Layer = require('./layer');
|
||||
var methods = require('methods');
|
||||
var mixin = require('utils-merge');
|
||||
var debug = require('debug')('express:router');
|
||||
var deprecate = require('depd')('express');
|
||||
var flatten = require('array-flatten');
|
||||
var parseUrl = require('parseurl');
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var objectRegExp = /^\[object (\S+)\]$/;
|
||||
var slice = Array.prototype.slice;
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Initialize a new `Router` with the given `options`.
|
||||
*
|
||||
* @param {Object} [options]
|
||||
* @return {Router} which is an callable function
|
||||
* @public
|
||||
*/
|
||||
|
||||
var proto = module.exports = function(options) {
|
||||
var opts = options || {};
|
||||
|
||||
function router(req, res, next) {
|
||||
router.handle(req, res, next);
|
||||
}
|
||||
|
||||
// mixin Router class functions
|
||||
setPrototypeOf(router, proto)
|
||||
|
||||
router.params = {};
|
||||
router._params = [];
|
||||
router.caseSensitive = opts.caseSensitive;
|
||||
router.mergeParams = opts.mergeParams;
|
||||
router.strict = opts.strict;
|
||||
router.stack = [];
|
||||
|
||||
return router;
|
||||
};
|
||||
|
||||
/**
|
||||
* Map the given param placeholder `name`(s) to the given callback.
|
||||
*
|
||||
* Parameter mapping is used to provide pre-conditions to routes
|
||||
* which use normalized placeholders. For example a _:user_id_ parameter
|
||||
* could automatically load a user's information from the database without
|
||||
* any additional code,
|
||||
*
|
||||
* The callback uses the same signature as middleware, the only difference
|
||||
* being that the value of the placeholder is passed, in this case the _id_
|
||||
* of the user. Once the `next()` function is invoked, just like middleware
|
||||
* it will continue on to execute the route, or subsequent parameter functions.
|
||||
*
|
||||
* Just like in middleware, you must either respond to the request or call next
|
||||
* to avoid stalling the request.
|
||||
*
|
||||
* app.param('user_id', function(req, res, next, id){
|
||||
* User.find(id, function(err, user){
|
||||
* if (err) {
|
||||
* return next(err);
|
||||
* } else if (!user) {
|
||||
* return next(new Error('failed to load user'));
|
||||
* }
|
||||
* req.user = user;
|
||||
* next();
|
||||
* });
|
||||
* });
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Function} fn
|
||||
* @return {app} for chaining
|
||||
* @public
|
||||
*/
|
||||
|
||||
proto.param = function param(name, fn) {
|
||||
// param logic
|
||||
if (typeof name === 'function') {
|
||||
deprecate('router.param(fn): Refactor to use path params');
|
||||
this._params.push(name);
|
||||
return;
|
||||
}
|
||||
|
||||
// apply param functions
|
||||
var params = this._params;
|
||||
var len = params.length;
|
||||
var ret;
|
||||
|
||||
if (name[0] === ':') {
|
||||
deprecate('router.param(' + JSON.stringify(name) + ', fn): Use router.param(' + JSON.stringify(name.substr(1)) + ', fn) instead');
|
||||
name = name.substr(1);
|
||||
}
|
||||
|
||||
for (var i = 0; i < len; ++i) {
|
||||
if (ret = params[i](name, fn)) {
|
||||
fn = ret;
|
||||
}
|
||||
}
|
||||
|
||||
// ensure we end up with a
|
||||
// middleware function
|
||||
if ('function' !== typeof fn) {
|
||||
throw new Error('invalid param() call for ' + name + ', got ' + fn);
|
||||
}
|
||||
|
||||
(this.params[name] = this.params[name] || []).push(fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispatch a req, res into the router.
|
||||
* @private
|
||||
*/
|
||||
|
||||
proto.handle = function handle(req, res, out) {
|
||||
var self = this;
|
||||
|
||||
debug('dispatching %s %s', req.method, req.url);
|
||||
|
||||
var idx = 0;
|
||||
var protohost = getProtohost(req.url) || ''
|
||||
var removed = '';
|
||||
var slashAdded = false;
|
||||
var paramcalled = {};
|
||||
|
||||
// store options for OPTIONS request
|
||||
// only used if OPTIONS request
|
||||
var options = [];
|
||||
|
||||
// middleware and routes
|
||||
var stack = self.stack;
|
||||
|
||||
// manage inter-router variables
|
||||
var parentParams = req.params;
|
||||
var parentUrl = req.baseUrl || '';
|
||||
var done = restore(out, req, 'baseUrl', 'next', 'params');
|
||||
|
||||
// setup next layer
|
||||
req.next = next;
|
||||
|
||||
// for options requests, respond with a default if nothing else responds
|
||||
if (req.method === 'OPTIONS') {
|
||||
done = wrap(done, function(old, err) {
|
||||
if (err || options.length === 0) return old(err);
|
||||
sendOptionsResponse(res, options, old);
|
||||
});
|
||||
}
|
||||
|
||||
// setup basic req values
|
||||
req.baseUrl = parentUrl;
|
||||
req.originalUrl = req.originalUrl || req.url;
|
||||
|
||||
next();
|
||||
|
||||
function next(err) {
|
||||
var layerError = err === 'route'
|
||||
? null
|
||||
: err;
|
||||
|
||||
// remove added slash
|
||||
if (slashAdded) {
|
||||
req.url = req.url.substr(1);
|
||||
slashAdded = false;
|
||||
}
|
||||
|
||||
// restore altered req.url
|
||||
if (removed.length !== 0) {
|
||||
req.baseUrl = parentUrl;
|
||||
req.url = protohost + removed + req.url.substr(protohost.length);
|
||||
removed = '';
|
||||
}
|
||||
|
||||
// signal to exit router
|
||||
if (layerError === 'router') {
|
||||
setImmediate(done, null)
|
||||
return
|
||||
}
|
||||
|
||||
// no more matching layers
|
||||
if (idx >= stack.length) {
|
||||
setImmediate(done, layerError);
|
||||
return;
|
||||
}
|
||||
|
||||
// get pathname of request
|
||||
var path = getPathname(req);
|
||||
|
||||
if (path == null) {
|
||||
return done(layerError);
|
||||
}
|
||||
|
||||
// find next matching layer
|
||||
var layer;
|
||||
var match;
|
||||
var route;
|
||||
|
||||
while (match !== true && idx < stack.length) {
|
||||
layer = stack[idx++];
|
||||
match = matchLayer(layer, path);
|
||||
route = layer.route;
|
||||
|
||||
if (typeof match !== 'boolean') {
|
||||
// hold on to layerError
|
||||
layerError = layerError || match;
|
||||
}
|
||||
|
||||
if (match !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!route) {
|
||||
// process non-route handlers normally
|
||||
continue;
|
||||
}
|
||||
|
||||
if (layerError) {
|
||||
// routes do not match with a pending error
|
||||
match = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
var method = req.method;
|
||||
var has_method = route._handles_method(method);
|
||||
|
||||
// build up automatic options response
|
||||
if (!has_method && method === 'OPTIONS') {
|
||||
appendMethods(options, route._options());
|
||||
}
|
||||
|
||||
// don't even bother matching route
|
||||
if (!has_method && method !== 'HEAD') {
|
||||
match = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// no match
|
||||
if (match !== true) {
|
||||
return done(layerError);
|
||||
}
|
||||
|
||||
// store route for dispatch on change
|
||||
if (route) {
|
||||
req.route = route;
|
||||
}
|
||||
|
||||
// Capture one-time layer values
|
||||
req.params = self.mergeParams
|
||||
? mergeParams(layer.params, parentParams)
|
||||
: layer.params;
|
||||
var layerPath = layer.path;
|
||||
|
||||
// this should be done for the layer
|
||||
self.process_params(layer, paramcalled, req, res, function (err) {
|
||||
if (err) {
|
||||
return next(layerError || err);
|
||||
}
|
||||
|
||||
if (route) {
|
||||
return layer.handle_request(req, res, next);
|
||||
}
|
||||
|
||||
trim_prefix(layer, layerError, layerPath, path);
|
||||
});
|
||||
}
|
||||
|
||||
function trim_prefix(layer, layerError, layerPath, path) {
|
||||
if (layerPath.length !== 0) {
|
||||
// Validate path breaks on a path separator
|
||||
var c = path[layerPath.length]
|
||||
if (c && c !== '/' && c !== '.') return next(layerError)
|
||||
|
||||
// Trim off the part of the url that matches the route
|
||||
// middleware (.use stuff) needs to have the path stripped
|
||||
debug('trim prefix (%s) from url %s', layerPath, req.url);
|
||||
removed = layerPath;
|
||||
req.url = protohost + req.url.substr(protohost.length + removed.length);
|
||||
|
||||
// Ensure leading slash
|
||||
if (!protohost && req.url[0] !== '/') {
|
||||
req.url = '/' + req.url;
|
||||
slashAdded = true;
|
||||
}
|
||||
|
||||
// Setup base URL (no trailing slash)
|
||||
req.baseUrl = parentUrl + (removed[removed.length - 1] === '/'
|
||||
? removed.substring(0, removed.length - 1)
|
||||
: removed);
|
||||
}
|
||||
|
||||
debug('%s %s : %s', layer.name, layerPath, req.originalUrl);
|
||||
|
||||
if (layerError) {
|
||||
layer.handle_error(layerError, req, res, next);
|
||||
} else {
|
||||
layer.handle_request(req, res, next);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Process any parameters for the layer.
|
||||
* @private
|
||||
*/
|
||||
|
||||
proto.process_params = function process_params(layer, called, req, res, done) {
|
||||
var params = this.params;
|
||||
|
||||
// captured parameters from the layer, keys and values
|
||||
var keys = layer.keys;
|
||||
|
||||
// fast track
|
||||
if (!keys || keys.length === 0) {
|
||||
return done();
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var name;
|
||||
var paramIndex = 0;
|
||||
var key;
|
||||
var paramVal;
|
||||
var paramCallbacks;
|
||||
var paramCalled;
|
||||
|
||||
// process params in order
|
||||
// param callbacks can be async
|
||||
function param(err) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
if (i >= keys.length ) {
|
||||
return done();
|
||||
}
|
||||
|
||||
paramIndex = 0;
|
||||
key = keys[i++];
|
||||
name = key.name;
|
||||
paramVal = req.params[name];
|
||||
paramCallbacks = params[name];
|
||||
paramCalled = called[name];
|
||||
|
||||
if (paramVal === undefined || !paramCallbacks) {
|
||||
return param();
|
||||
}
|
||||
|
||||
// param previously called with same value or error occurred
|
||||
if (paramCalled && (paramCalled.match === paramVal
|
||||
|| (paramCalled.error && paramCalled.error !== 'route'))) {
|
||||
// restore value
|
||||
req.params[name] = paramCalled.value;
|
||||
|
||||
// next param
|
||||
return param(paramCalled.error);
|
||||
}
|
||||
|
||||
called[name] = paramCalled = {
|
||||
error: null,
|
||||
match: paramVal,
|
||||
value: paramVal
|
||||
};
|
||||
|
||||
paramCallback();
|
||||
}
|
||||
|
||||
// single param callbacks
|
||||
function paramCallback(err) {
|
||||
var fn = paramCallbacks[paramIndex++];
|
||||
|
||||
// store updated value
|
||||
paramCalled.value = req.params[key.name];
|
||||
|
||||
if (err) {
|
||||
// store error
|
||||
paramCalled.error = err;
|
||||
param(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fn) return param();
|
||||
|
||||
try {
|
||||
fn(req, res, paramCallback, paramVal, key.name);
|
||||
} catch (e) {
|
||||
paramCallback(e);
|
||||
}
|
||||
}
|
||||
|
||||
param();
|
||||
};
|
||||
|
||||
/**
|
||||
* Use the given middleware function, with optional path, defaulting to "/".
|
||||
*
|
||||
* Use (like `.all`) will run for any http METHOD, but it will not add
|
||||
* handlers for those methods so OPTIONS requests will not consider `.use`
|
||||
* functions even if they could respond.
|
||||
*
|
||||
* The other difference is that _route_ path is stripped and not visible
|
||||
* to the handler function. The main effect of this feature is that mounted
|
||||
* handlers can operate without any code changes regardless of the "prefix"
|
||||
* pathname.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
proto.use = function use(fn) {
|
||||
var offset = 0;
|
||||
var path = '/';
|
||||
|
||||
// default path to '/'
|
||||
// disambiguate router.use([fn])
|
||||
if (typeof fn !== 'function') {
|
||||
var arg = fn;
|
||||
|
||||
while (Array.isArray(arg) && arg.length !== 0) {
|
||||
arg = arg[0];
|
||||
}
|
||||
|
||||
// first arg is the path
|
||||
if (typeof arg !== 'function') {
|
||||
offset = 1;
|
||||
path = fn;
|
||||
}
|
||||
}
|
||||
|
||||
var callbacks = flatten(slice.call(arguments, offset));
|
||||
|
||||
if (callbacks.length === 0) {
|
||||
throw new TypeError('Router.use() requires a middleware function')
|
||||
}
|
||||
|
||||
for (var i = 0; i < callbacks.length; i++) {
|
||||
var fn = callbacks[i];
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
|
||||
}
|
||||
|
||||
// add the middleware
|
||||
debug('use %o %s', path, fn.name || '<anonymous>')
|
||||
|
||||
var layer = new Layer(path, {
|
||||
sensitive: this.caseSensitive,
|
||||
strict: false,
|
||||
end: false
|
||||
}, fn);
|
||||
|
||||
layer.route = undefined;
|
||||
|
||||
this.stack.push(layer);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new Route for the given path.
|
||||
*
|
||||
* Each route contains a separate middleware stack and VERB handlers.
|
||||
*
|
||||
* See the Route api documentation for details on adding handlers
|
||||
* and middleware to routes.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Route}
|
||||
* @public
|
||||
*/
|
||||
|
||||
proto.route = function route(path) {
|
||||
var route = new Route(path);
|
||||
|
||||
var layer = new Layer(path, {
|
||||
sensitive: this.caseSensitive,
|
||||
strict: this.strict,
|
||||
end: true
|
||||
}, route.dispatch.bind(route));
|
||||
|
||||
layer.route = route;
|
||||
|
||||
this.stack.push(layer);
|
||||
return route;
|
||||
};
|
||||
|
||||
// create Router#VERB functions
|
||||
methods.concat('all').forEach(function(method){
|
||||
proto[method] = function(path){
|
||||
var route = this.route(path)
|
||||
route[method].apply(route, slice.call(arguments, 1));
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
// append methods to a list of methods
|
||||
function appendMethods(list, addition) {
|
||||
for (var i = 0; i < addition.length; i++) {
|
||||
var method = addition[i];
|
||||
if (list.indexOf(method) === -1) {
|
||||
list.push(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get pathname of request
|
||||
function getPathname(req) {
|
||||
try {
|
||||
return parseUrl(req).pathname;
|
||||
} catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Get get protocol + host for a URL
|
||||
function getProtohost(url) {
|
||||
if (typeof url !== 'string' || url.length === 0 || url[0] === '/') {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var searchIndex = url.indexOf('?')
|
||||
var pathLength = searchIndex !== -1
|
||||
? searchIndex
|
||||
: url.length
|
||||
var fqdnIndex = url.substr(0, pathLength).indexOf('://')
|
||||
|
||||
return fqdnIndex !== -1
|
||||
? url.substr(0, url.indexOf('/', 3 + fqdnIndex))
|
||||
: undefined
|
||||
}
|
||||
|
||||
// get type for error message
|
||||
function gettype(obj) {
|
||||
var type = typeof obj;
|
||||
|
||||
if (type !== 'object') {
|
||||
return type;
|
||||
}
|
||||
|
||||
// inspect [[Class]] for objects
|
||||
return toString.call(obj)
|
||||
.replace(objectRegExp, '$1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Match path to a layer.
|
||||
*
|
||||
* @param {Layer} layer
|
||||
* @param {string} path
|
||||
* @private
|
||||
*/
|
||||
|
||||
function matchLayer(layer, path) {
|
||||
try {
|
||||
return layer.match(path);
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
// merge params with parent params
|
||||
function mergeParams(params, parent) {
|
||||
if (typeof parent !== 'object' || !parent) {
|
||||
return params;
|
||||
}
|
||||
|
||||
// make copy of parent for base
|
||||
var obj = mixin({}, parent);
|
||||
|
||||
// simple non-numeric merging
|
||||
if (!(0 in params) || !(0 in parent)) {
|
||||
return mixin(obj, params);
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var o = 0;
|
||||
|
||||
// determine numeric gaps
|
||||
while (i in params) {
|
||||
i++;
|
||||
}
|
||||
|
||||
while (o in parent) {
|
||||
o++;
|
||||
}
|
||||
|
||||
// offset numeric indices in params before merge
|
||||
for (i--; i >= 0; i--) {
|
||||
params[i + o] = params[i];
|
||||
|
||||
// create holes for the merge when necessary
|
||||
if (i < o) {
|
||||
delete params[i];
|
||||
}
|
||||
}
|
||||
|
||||
return mixin(obj, params);
|
||||
}
|
||||
|
||||
// restore obj props after function
|
||||
function restore(fn, obj) {
|
||||
var props = new Array(arguments.length - 2);
|
||||
var vals = new Array(arguments.length - 2);
|
||||
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
props[i] = arguments[i + 2];
|
||||
vals[i] = obj[props[i]];
|
||||
}
|
||||
|
||||
return function () {
|
||||
// restore vals
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
obj[props[i]] = vals[i];
|
||||
}
|
||||
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// send an OPTIONS response
|
||||
function sendOptionsResponse(res, options, next) {
|
||||
try {
|
||||
var body = options.join(',');
|
||||
res.set('Allow', body);
|
||||
res.send(body);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
||||
// wrap a function
|
||||
function wrap(old, fn) {
|
||||
return function proxy() {
|
||||
var args = new Array(arguments.length + 1);
|
||||
|
||||
args[0] = old;
|
||||
for (var i = 0, len = arguments.length; i < len; i++) {
|
||||
args[i + 1] = arguments[i];
|
||||
}
|
||||
|
||||
fn.apply(this, args);
|
||||
};
|
||||
}
|
||||
Generated
Vendored
+181
@@ -0,0 +1,181 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var pathRegexp = require('path-to-regexp');
|
||||
var debug = require('debug')('express:router:layer');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = Layer;
|
||||
|
||||
function Layer(path, options, fn) {
|
||||
if (!(this instanceof Layer)) {
|
||||
return new Layer(path, options, fn);
|
||||
}
|
||||
|
||||
debug('new %o', path)
|
||||
var opts = options || {};
|
||||
|
||||
this.handle = fn;
|
||||
this.name = fn.name || '<anonymous>';
|
||||
this.params = undefined;
|
||||
this.path = undefined;
|
||||
this.regexp = pathRegexp(path, this.keys = [], opts);
|
||||
|
||||
// set fast path flags
|
||||
this.regexp.fast_star = path === '*'
|
||||
this.regexp.fast_slash = path === '/' && opts.end === false
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the error for the layer.
|
||||
*
|
||||
* @param {Error} error
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {function} next
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.handle_error = function handle_error(error, req, res, next) {
|
||||
var fn = this.handle;
|
||||
|
||||
if (fn.length !== 4) {
|
||||
// not a standard error handler
|
||||
return next(error);
|
||||
}
|
||||
|
||||
try {
|
||||
fn(error, req, res, next);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle the request for the layer.
|
||||
*
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {function} next
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.handle_request = function handle(req, res, next) {
|
||||
var fn = this.handle;
|
||||
|
||||
if (fn.length > 3) {
|
||||
// not a standard request handler
|
||||
return next();
|
||||
}
|
||||
|
||||
try {
|
||||
fn(req, res, next);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this route matches `path`, if so
|
||||
* populate `.params`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.match = function match(path) {
|
||||
var match
|
||||
|
||||
if (path != null) {
|
||||
// fast path non-ending match for / (any path matches)
|
||||
if (this.regexp.fast_slash) {
|
||||
this.params = {}
|
||||
this.path = ''
|
||||
return true
|
||||
}
|
||||
|
||||
// fast path for * (everything matched in a param)
|
||||
if (this.regexp.fast_star) {
|
||||
this.params = {'0': decode_param(path)}
|
||||
this.path = path
|
||||
return true
|
||||
}
|
||||
|
||||
// match the path
|
||||
match = this.regexp.exec(path)
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
this.params = undefined;
|
||||
this.path = undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
// store values
|
||||
this.params = {};
|
||||
this.path = match[0]
|
||||
|
||||
var keys = this.keys;
|
||||
var params = this.params;
|
||||
|
||||
for (var i = 1; i < match.length; i++) {
|
||||
var key = keys[i - 1];
|
||||
var prop = key.name;
|
||||
var val = decode_param(match[i])
|
||||
|
||||
if (val !== undefined || !(hasOwnProperty.call(params, prop))) {
|
||||
params[prop] = val;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode param value.
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function decode_param(val) {
|
||||
if (typeof val !== 'string' || val.length === 0) {
|
||||
return val;
|
||||
}
|
||||
|
||||
try {
|
||||
return decodeURIComponent(val);
|
||||
} catch (err) {
|
||||
if (err instanceof URIError) {
|
||||
err.message = 'Failed to decode param \'' + val + '\'';
|
||||
err.status = err.statusCode = 400;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+216
@@ -0,0 +1,216 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var debug = require('debug')('express:router:route');
|
||||
var flatten = require('array-flatten');
|
||||
var Layer = require('./layer');
|
||||
var methods = require('methods');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var slice = Array.prototype.slice;
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = Route;
|
||||
|
||||
/**
|
||||
* Initialize `Route` with the given `path`,
|
||||
*
|
||||
* @param {String} path
|
||||
* @public
|
||||
*/
|
||||
|
||||
function Route(path) {
|
||||
this.path = path;
|
||||
this.stack = [];
|
||||
|
||||
debug('new %o', path)
|
||||
|
||||
// route handlers for various http methods
|
||||
this.methods = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the route handles a given method.
|
||||
* @private
|
||||
*/
|
||||
|
||||
Route.prototype._handles_method = function _handles_method(method) {
|
||||
if (this.methods._all) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var name = method.toLowerCase();
|
||||
|
||||
if (name === 'head' && !this.methods['head']) {
|
||||
name = 'get';
|
||||
}
|
||||
|
||||
return Boolean(this.methods[name]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Array} supported HTTP methods
|
||||
* @private
|
||||
*/
|
||||
|
||||
Route.prototype._options = function _options() {
|
||||
var methods = Object.keys(this.methods);
|
||||
|
||||
// append automatic head
|
||||
if (this.methods.get && !this.methods.head) {
|
||||
methods.push('head');
|
||||
}
|
||||
|
||||
for (var i = 0; i < methods.length; i++) {
|
||||
// make upper case
|
||||
methods[i] = methods[i].toUpperCase();
|
||||
}
|
||||
|
||||
return methods;
|
||||
};
|
||||
|
||||
/**
|
||||
* dispatch req, res into this route
|
||||
* @private
|
||||
*/
|
||||
|
||||
Route.prototype.dispatch = function dispatch(req, res, done) {
|
||||
var idx = 0;
|
||||
var stack = this.stack;
|
||||
if (stack.length === 0) {
|
||||
return done();
|
||||
}
|
||||
|
||||
var method = req.method.toLowerCase();
|
||||
if (method === 'head' && !this.methods['head']) {
|
||||
method = 'get';
|
||||
}
|
||||
|
||||
req.route = this;
|
||||
|
||||
next();
|
||||
|
||||
function next(err) {
|
||||
// signal to exit route
|
||||
if (err && err === 'route') {
|
||||
return done();
|
||||
}
|
||||
|
||||
// signal to exit router
|
||||
if (err && err === 'router') {
|
||||
return done(err)
|
||||
}
|
||||
|
||||
var layer = stack[idx++];
|
||||
if (!layer) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
if (layer.method && layer.method !== method) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
layer.handle_error(err, req, res, next);
|
||||
} else {
|
||||
layer.handle_request(req, res, next);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a handler for all HTTP verbs to this route.
|
||||
*
|
||||
* Behaves just like middleware and can respond or call `next`
|
||||
* to continue processing.
|
||||
*
|
||||
* You can use multiple `.all` call to add multiple handlers.
|
||||
*
|
||||
* function check_something(req, res, next){
|
||||
* next();
|
||||
* };
|
||||
*
|
||||
* function validate_user(req, res, next){
|
||||
* next();
|
||||
* };
|
||||
*
|
||||
* route
|
||||
* .all(validate_user)
|
||||
* .all(check_something)
|
||||
* .get(function(req, res, next){
|
||||
* res.send('hello world');
|
||||
* });
|
||||
*
|
||||
* @param {function} handler
|
||||
* @return {Route} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Route.prototype.all = function all() {
|
||||
var handles = flatten(slice.call(arguments));
|
||||
|
||||
for (var i = 0; i < handles.length; i++) {
|
||||
var handle = handles[i];
|
||||
|
||||
if (typeof handle !== 'function') {
|
||||
var type = toString.call(handle);
|
||||
var msg = 'Route.all() requires a callback function but got a ' + type
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
|
||||
var layer = Layer('/', {}, handle);
|
||||
layer.method = undefined;
|
||||
|
||||
this.methods._all = true;
|
||||
this.stack.push(layer);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
methods.forEach(function(method){
|
||||
Route.prototype[method] = function(){
|
||||
var handles = flatten(slice.call(arguments));
|
||||
|
||||
for (var i = 0; i < handles.length; i++) {
|
||||
var handle = handles[i];
|
||||
|
||||
if (typeof handle !== 'function') {
|
||||
var type = toString.call(handle);
|
||||
var msg = 'Route.' + method + '() requires a callback function but got a ' + type
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
debug('%s %o', method, this.path)
|
||||
|
||||
var layer = Layer('/', {}, handle);
|
||||
layer.method = method;
|
||||
|
||||
this.methods[method] = true;
|
||||
this.stack.push(layer);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
});
|
||||
Generated
Vendored
+306
@@ -0,0 +1,306 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @api private
|
||||
*/
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var contentDisposition = require('content-disposition');
|
||||
var contentType = require('content-type');
|
||||
var deprecate = require('depd')('express');
|
||||
var flatten = require('array-flatten');
|
||||
var mime = require('send').mime;
|
||||
var etag = require('etag');
|
||||
var proxyaddr = require('proxy-addr');
|
||||
var qs = require('qs');
|
||||
var querystring = require('querystring');
|
||||
|
||||
/**
|
||||
* Return strong ETag for `body`.
|
||||
*
|
||||
* @param {String|Buffer} body
|
||||
* @param {String} [encoding]
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.etag = createETagGenerator({ weak: false })
|
||||
|
||||
/**
|
||||
* Return weak ETag for `body`.
|
||||
*
|
||||
* @param {String|Buffer} body
|
||||
* @param {String} [encoding]
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.wetag = createETagGenerator({ weak: true })
|
||||
|
||||
/**
|
||||
* Check if `path` looks absolute.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.isAbsolute = function(path){
|
||||
if ('/' === path[0]) return true;
|
||||
if (':' === path[1] && ('\\' === path[2] || '/' === path[2])) return true; // Windows device path
|
||||
if ('\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path
|
||||
};
|
||||
|
||||
/**
|
||||
* Flatten the given `arr`.
|
||||
*
|
||||
* @param {Array} arr
|
||||
* @return {Array}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.flatten = deprecate.function(flatten,
|
||||
'utils.flatten: use array-flatten npm module instead');
|
||||
|
||||
/**
|
||||
* Normalize the given `type`, for example "html" becomes "text/html".
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.normalizeType = function(type){
|
||||
return ~type.indexOf('/')
|
||||
? acceptParams(type)
|
||||
: { value: mime.lookup(type), params: {} };
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize `types`, for example "html" becomes "text/html".
|
||||
*
|
||||
* @param {Array} types
|
||||
* @return {Array}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.normalizeTypes = function(types){
|
||||
var ret = [];
|
||||
|
||||
for (var i = 0; i < types.length; ++i) {
|
||||
ret.push(exports.normalizeType(types[i]));
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate Content-Disposition header appropriate for the filename.
|
||||
* non-ascii filenames are urlencoded and a filename* parameter is added
|
||||
*
|
||||
* @param {String} filename
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.contentDisposition = deprecate.function(contentDisposition,
|
||||
'utils.contentDisposition: use content-disposition npm module instead');
|
||||
|
||||
/**
|
||||
* Parse accept params `str` returning an
|
||||
* object with `.value`, `.quality` and `.params`.
|
||||
* also includes `.originalIndex` for stable sorting
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function acceptParams(str, index) {
|
||||
var parts = str.split(/ *; */);
|
||||
var ret = { value: parts[0], quality: 1, params: {}, originalIndex: index };
|
||||
|
||||
for (var i = 1; i < parts.length; ++i) {
|
||||
var pms = parts[i].split(/ *= */);
|
||||
if ('q' === pms[0]) {
|
||||
ret.quality = parseFloat(pms[1]);
|
||||
} else {
|
||||
ret.params[pms[0]] = pms[1];
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile "etag" value to function.
|
||||
*
|
||||
* @param {Boolean|String|Function} val
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.compileETag = function(val) {
|
||||
var fn;
|
||||
|
||||
if (typeof val === 'function') {
|
||||
return val;
|
||||
}
|
||||
|
||||
switch (val) {
|
||||
case true:
|
||||
fn = exports.wetag;
|
||||
break;
|
||||
case false:
|
||||
break;
|
||||
case 'strong':
|
||||
fn = exports.etag;
|
||||
break;
|
||||
case 'weak':
|
||||
fn = exports.wetag;
|
||||
break;
|
||||
default:
|
||||
throw new TypeError('unknown value for etag function: ' + val);
|
||||
}
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile "query parser" value to function.
|
||||
*
|
||||
* @param {String|Function} val
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.compileQueryParser = function compileQueryParser(val) {
|
||||
var fn;
|
||||
|
||||
if (typeof val === 'function') {
|
||||
return val;
|
||||
}
|
||||
|
||||
switch (val) {
|
||||
case true:
|
||||
fn = querystring.parse;
|
||||
break;
|
||||
case false:
|
||||
fn = newObject;
|
||||
break;
|
||||
case 'extended':
|
||||
fn = parseExtendedQueryString;
|
||||
break;
|
||||
case 'simple':
|
||||
fn = querystring.parse;
|
||||
break;
|
||||
default:
|
||||
throw new TypeError('unknown value for query parser function: ' + val);
|
||||
}
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile "proxy trust" value to function.
|
||||
*
|
||||
* @param {Boolean|String|Number|Array|Function} val
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.compileTrust = function(val) {
|
||||
if (typeof val === 'function') return val;
|
||||
|
||||
if (val === true) {
|
||||
// Support plain true/false
|
||||
return function(){ return true };
|
||||
}
|
||||
|
||||
if (typeof val === 'number') {
|
||||
// Support trusting hop count
|
||||
return function(a, i){ return i < val };
|
||||
}
|
||||
|
||||
if (typeof val === 'string') {
|
||||
// Support comma-separated values
|
||||
val = val.split(/ *, */);
|
||||
}
|
||||
|
||||
return proxyaddr.compile(val || []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the charset in a given Content-Type string.
|
||||
*
|
||||
* @param {String} type
|
||||
* @param {String} charset
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.setCharset = function setCharset(type, charset) {
|
||||
if (!type || !charset) {
|
||||
return type;
|
||||
}
|
||||
|
||||
// parse type
|
||||
var parsed = contentType.parse(type);
|
||||
|
||||
// set charset
|
||||
parsed.parameters.charset = charset;
|
||||
|
||||
// format type
|
||||
return contentType.format(parsed);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create an ETag generator function, generating ETags with
|
||||
* the given options.
|
||||
*
|
||||
* @param {object} options
|
||||
* @return {function}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function createETagGenerator (options) {
|
||||
return function generateETag (body, encoding) {
|
||||
var buf = !Buffer.isBuffer(body)
|
||||
? Buffer.from(body, encoding)
|
||||
: body
|
||||
|
||||
return etag(buf, options)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an extended query string with qs.
|
||||
*
|
||||
* @return {Object}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function parseExtendedQueryString(str) {
|
||||
return qs.parse(str, {
|
||||
allowPrototypes: true
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return new empty object.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function newObject() {
|
||||
return {};
|
||||
}
|
||||
Generated
Vendored
+182
@@ -0,0 +1,182 @@
|
||||
/*!
|
||||
* express
|
||||
* Copyright(c) 2009-2013 TJ Holowaychuk
|
||||
* Copyright(c) 2013 Roman Shtylman
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var debug = require('debug')('express:view');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var dirname = path.dirname;
|
||||
var basename = path.basename;
|
||||
var extname = path.extname;
|
||||
var join = path.join;
|
||||
var resolve = path.resolve;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = View;
|
||||
|
||||
/**
|
||||
* Initialize a new `View` with the given `name`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `defaultEngine` the default template engine name
|
||||
* - `engines` template engine require() cache
|
||||
* - `root` root path for view lookup
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {object} options
|
||||
* @public
|
||||
*/
|
||||
|
||||
function View(name, options) {
|
||||
var opts = options || {};
|
||||
|
||||
this.defaultEngine = opts.defaultEngine;
|
||||
this.ext = extname(name);
|
||||
this.name = name;
|
||||
this.root = opts.root;
|
||||
|
||||
if (!this.ext && !this.defaultEngine) {
|
||||
throw new Error('No default engine was specified and no extension was provided.');
|
||||
}
|
||||
|
||||
var fileName = name;
|
||||
|
||||
if (!this.ext) {
|
||||
// get extension from default engine name
|
||||
this.ext = this.defaultEngine[0] !== '.'
|
||||
? '.' + this.defaultEngine
|
||||
: this.defaultEngine;
|
||||
|
||||
fileName += this.ext;
|
||||
}
|
||||
|
||||
if (!opts.engines[this.ext]) {
|
||||
// load engine
|
||||
var mod = this.ext.substr(1)
|
||||
debug('require "%s"', mod)
|
||||
|
||||
// default engine export
|
||||
var fn = require(mod).__express
|
||||
|
||||
if (typeof fn !== 'function') {
|
||||
throw new Error('Module "' + mod + '" does not provide a view engine.')
|
||||
}
|
||||
|
||||
opts.engines[this.ext] = fn
|
||||
}
|
||||
|
||||
// store loaded engine
|
||||
this.engine = opts.engines[this.ext];
|
||||
|
||||
// lookup path
|
||||
this.path = this.lookup(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup view by the given `name`
|
||||
*
|
||||
* @param {string} name
|
||||
* @private
|
||||
*/
|
||||
|
||||
View.prototype.lookup = function lookup(name) {
|
||||
var path;
|
||||
var roots = [].concat(this.root);
|
||||
|
||||
debug('lookup "%s"', name);
|
||||
|
||||
for (var i = 0; i < roots.length && !path; i++) {
|
||||
var root = roots[i];
|
||||
|
||||
// resolve the path
|
||||
var loc = resolve(root, name);
|
||||
var dir = dirname(loc);
|
||||
var file = basename(loc);
|
||||
|
||||
// resolve the file
|
||||
path = this.resolve(dir, file);
|
||||
}
|
||||
|
||||
return path;
|
||||
};
|
||||
|
||||
/**
|
||||
* Render with the given options.
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {function} callback
|
||||
* @private
|
||||
*/
|
||||
|
||||
View.prototype.render = function render(options, callback) {
|
||||
debug('render "%s"', this.path);
|
||||
this.engine(this.path, options, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolve the file within the given directory.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {string} file
|
||||
* @private
|
||||
*/
|
||||
|
||||
View.prototype.resolve = function resolve(dir, file) {
|
||||
var ext = this.ext;
|
||||
|
||||
// <path>.<ext>
|
||||
var path = join(dir, file);
|
||||
var stat = tryStat(path);
|
||||
|
||||
if (stat && stat.isFile()) {
|
||||
return path;
|
||||
}
|
||||
|
||||
// <path>/index.<ext>
|
||||
path = join(dir, basename(file, ext), 'index' + ext);
|
||||
stat = tryStat(path);
|
||||
|
||||
if (stat && stat.isFile()) {
|
||||
return path;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a stat, maybe.
|
||||
*
|
||||
* @param {string} path
|
||||
* @return {fs.Stats}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function tryStat(path) {
|
||||
debug('stat "%s"', path);
|
||||
|
||||
try {
|
||||
return fs.statSync(path);
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+160
@@ -0,0 +1,160 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"express@4.17.1",
|
||||
"C:\\Users\\tiago.kayaya\\development\\gabinete-digital"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "express@4.17.1",
|
||||
"_id": "express@4.17.1",
|
||||
"_inBundle": true,
|
||||
"_integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
|
||||
"_location": "/cordova-plugin-mfp/express",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "express@4.17.1",
|
||||
"name": "express",
|
||||
"escapedName": "express",
|
||||
"rawSpec": "4.17.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.17.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cordova-plugin-mfp",
|
||||
"/cordova-plugin-mfp/cordova-serve"
|
||||
],
|
||||
"_resolved": false,
|
||||
"_shasum": "4491fc38605cf51f8629d39c2b5d026f98a4c134",
|
||||
"_spec": "4.17.1",
|
||||
"_where": "C:\\Users\\tiago.kayaya\\development\\gabinete-digital",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/expressjs/express/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Aaron Heckmann",
|
||||
"email": "aaron.heckmann+github@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Ciaran Jessup",
|
||||
"email": "ciaranj@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "Guillermo Rauch",
|
||||
"email": "rauchg@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Shtylman",
|
||||
"email": "shtylman+expressjs@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Young Jae Sim",
|
||||
"email": "hanul@hanul.me"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.7",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "1.19.0",
|
||||
"content-disposition": "0.5.3",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.4.0",
|
||||
"cookie-signature": "1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "~1.1.2",
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "~1.1.2",
|
||||
"fresh": "0.5.2",
|
||||
"merge-descriptors": "1.0.1",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "~2.3.0",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "0.1.7",
|
||||
"proxy-addr": "~2.0.5",
|
||||
"qs": "6.7.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.1.2",
|
||||
"send": "0.17.1",
|
||||
"serve-static": "1.14.1",
|
||||
"setprototypeof": "1.1.1",
|
||||
"statuses": "~1.5.0",
|
||||
"type-is": "~1.6.18",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Fast, unopinionated, minimalist web framework",
|
||||
"devDependencies": {
|
||||
"after": "0.8.2",
|
||||
"connect-redis": "3.4.1",
|
||||
"cookie-parser": "~1.4.4",
|
||||
"cookie-session": "1.3.3",
|
||||
"ejs": "2.6.1",
|
||||
"eslint": "2.13.1",
|
||||
"express-session": "1.16.1",
|
||||
"hbs": "4.0.4",
|
||||
"istanbul": "0.4.5",
|
||||
"marked": "0.6.2",
|
||||
"method-override": "3.0.0",
|
||||
"mocha": "5.2.0",
|
||||
"morgan": "1.9.1",
|
||||
"multiparty": "4.2.1",
|
||||
"pbkdf2-password": "1.2.1",
|
||||
"should": "13.2.3",
|
||||
"supertest": "3.3.0",
|
||||
"vhost": "~3.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"History.md",
|
||||
"Readme.md",
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"homepage": "http://expressjs.com/",
|
||||
"keywords": [
|
||||
"express",
|
||||
"framework",
|
||||
"sinatra",
|
||||
"web",
|
||||
"rest",
|
||||
"restful",
|
||||
"router",
|
||||
"app",
|
||||
"api"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "express",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/expressjs/express.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",
|
||||
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/",
|
||||
"test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/"
|
||||
},
|
||||
"version": "4.17.1"
|
||||
}
|
||||
_platforms/browser/platform_www/plugins/cordova-plugin-mfp/worklight/node_modules/jssha/CHANGELOG.md
Generated
Vendored
+150
@@ -0,0 +1,150 @@
|
||||
jsSHA - ChangeLog
|
||||
=========================
|
||||
|
||||
2.2.0 (2016-07-10)
|
||||
-------------------------
|
||||
- Added support for the SHA-3 family of hashes (SHA3-224, SHA3-256,
|
||||
SHA3-384, SHA3-512, SHAKE128, and SHAKE256)
|
||||
- Fixed bug with using ARRAYBUFFER as a HMAC key type
|
||||
- Switched testing framework to Mocha and Chai
|
||||
|
||||
2.1.0 (2016-05-13)
|
||||
-------------------------
|
||||
- Added ability to call `update` on hashes between `getHash` and `getHMAC` calls
|
||||
- Added new input and output type, "ARRAYBUFFER" which is a JavaScript
|
||||
ArrayBuffer
|
||||
- Now keeping smaller build files in NPM (thanks vogievetsky!)
|
||||
- Fixed problem with hashing strings over 4 billion bits (thanks Eicar!)
|
||||
|
||||
2.0.2 (2015-10-31)
|
||||
-------------------------
|
||||
- Fixed inability to have a blank "b64Pad" (thanks xlc!)
|
||||
- Added file hashing test (thanks kofalt!)
|
||||
|
||||
2.0.1 (2015-06-25)
|
||||
-------------------------
|
||||
- Fixed major issue with all hashes failing if raw input was a particular size
|
||||
(thanks treus!)
|
||||
|
||||
2.0.0 (2015-06-13)
|
||||
-------------------------
|
||||
- Completely reworked API to support streaming inputs
|
||||
- Exceptions now throw Errors instead of strings (thanks jclem!)
|
||||
|
||||
1.6.1 (2015-06-25)
|
||||
-------------------------
|
||||
- Fixed issue with SHA-512 family of hashes failing is raw input was a
|
||||
particular size
|
||||
|
||||
1.6.0 (2015-03-08)
|
||||
-------------------------
|
||||
This marks the last v1.X new feature release. The API is changing
|
||||
significantly with upcoming v2.0 to support streaming and it will be too
|
||||
difficult to support the older API style with new features.
|
||||
|
||||
- Added a BYTES input and output format that is a raw byte string
|
||||
- Fixed broken AMD support (thanks drewcovi!)
|
||||
- Fixed broken UTF-8 parsing on non-BMP Unicode characters
|
||||
- Changed array references to remove warnings on Icedove
|
||||
- Replaced "UTF16" encoding with "UTF16BE" (big endian) and "UTF16LE" (little
|
||||
endian) to remove confusion
|
||||
|
||||
1.5.1 (2013-12-15)
|
||||
-------------------------
|
||||
- Changed Google Closure Compiler options to produce "strict" compatible code
|
||||
|
||||
1.5 (2013-12-15)
|
||||
-------------------------
|
||||
- Added optional numRounds argument to getHash
|
||||
- Note: this necessitated removing the hash result caching functionality
|
||||
- Reduced file size by optimizing internal constants
|
||||
- Removed charSize input and replaced with encoding to handle Unicode. NOTE:
|
||||
Only Code points up to 0xFFFF are supported.
|
||||
- charSize = 16 is effectively replaced by encoding = "UTF16"
|
||||
- charSize = 8 was wrong in terms of handling UTF-8 and has been replaced by
|
||||
encoding = "UTF8"
|
||||
- Changed method of referencing "window" to be compatible with WebWorkers,
|
||||
Node.js, and AMD (thanks piranna!)
|
||||
|
||||
1.42 (2012-12-28)
|
||||
-------------------------
|
||||
- Readded v1.4 Safari patch to support older versions
|
||||
|
||||
1.41 (2012-12-23)
|
||||
-------------------------
|
||||
- Fixed incorrect hash issue with Chrome x64 v25 (Dev channel), also provides
|
||||
stable patch to v1.4 Safari issue.
|
||||
|
||||
1.4 (2012-12-08)
|
||||
-------------------------
|
||||
- Added new input type, TEXT, that is functionally identical to ASCII*
|
||||
- Added new input type, B64, for base-64 encoded strings
|
||||
- Added new input and output formatting parameters
|
||||
- `getHash` and `getHMAC` take an optional parameter, outputFormatOpts,
|
||||
that is a hash list containing the keys "outputUpper" (boolean, only
|
||||
applicable to HEX output) and "b64Pad" (string, only applicable to Base-64
|
||||
output) that have default values of false and "=", respectively
|
||||
- jsSHA constructor takes an optional parameter, charSize (8 or 16) that
|
||||
specifies the character width of the input (TEXT and ASCII input only)
|
||||
- Modified comments to be Google Closure Compiler compliant
|
||||
- Added a SUPPORTED_ALGS flag that, when used with the Google Closure Compiler,
|
||||
will remove unused functions/function portions
|
||||
- Removed all src/*_nice.js files as the SUPPORTED_ALGS flag renders them
|
||||
obsolete
|
||||
- All production-ready files are now produced using the Google Closure Compiler
|
||||
with ADVANCED_OPTIMIZATIONS resulting in further reduced filesizes
|
||||
- The SHA-1 only implementation now requires that that "SHA-1" be specified as
|
||||
the variant when using getHash and getHMAC
|
||||
- Removed test/HMAC.py as new NIST tests made the need for it obsolete
|
||||
- Significantly changed the test/test.html to make it easier to understand and
|
||||
to allow for easier adding of test cases
|
||||
- Replaced previous error returning code with thrown exceptions
|
||||
- Fix for 64-bit Safari issue (thanks Ron Garret and Chris Warren-Smith!)
|
||||
- NOTE: While this fix works, it is merely a workaround for a WebKit JavaScript
|
||||
optimizer bug, see https://bugs.webkit.org/show_bug.cgi?id=88673 for more detail
|
||||
|
||||
\* This library misused the term ASCII so input type of TEXT was added with the
|
||||
intention of deprecating ASCII
|
||||
|
||||
1.31 (2012-07-21)
|
||||
-------------------------
|
||||
- Updated project URL to point to new GitHub repository
|
||||
- Added a compressed version of sha.js
|
||||
|
||||
1.3 (2010-09-01)
|
||||
-------------------------
|
||||
- Changed method of declaring objects/classes
|
||||
- Moved non-instance specific variables and methods to class scope
|
||||
- Removed logically correct but unneeded conditionals
|
||||
|
||||
1.2 (2009-07-22)
|
||||
-------------------------
|
||||
- Added the HMAC algorithm for all supported hashes (using both ASCII and hex
|
||||
keys)
|
||||
- As a result of adding HMAC, added support for hash input text to be hex
|
||||
(ASCII representation of hex)
|
||||
- Added multiple variants of safeAdd functions, resulting in a significant
|
||||
performance gain
|
||||
- Removed wrapper.js file
|
||||
- Used a different JavaScript compressor resulting in smaller file sizes
|
||||
|
||||
1.11 (2008-12-07)
|
||||
-------------------------
|
||||
- Fixed a base-64 encoding issue resulting from a missing capital 'X'
|
||||
|
||||
1.1 (2008-09-25)
|
||||
-------------------------
|
||||
- Fixed an issue with incorrect hashes being generated when jsSHA ojbects were
|
||||
used to generate multiple hashes
|
||||
|
||||
1.0 (2008-09-25)
|
||||
-------------------------
|
||||
- Made all functions/variables follow an object-orientated methodology
|
||||
- Removed support for string hash output as the hash is rarely ASCII friendly
|
||||
- Changed the interface to calculate hashes (see README)
|
||||
- Made sha.js validate against [JSLint](http://www.jslint.com/) using
|
||||
"Recommended" settings
|
||||
|
||||
0.1 (2008-02-21)
|
||||
-------------------------
|
||||
- Initial public release
|
||||
Generated
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
Copyright (c) 2008-2016, Brian Turek
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of the the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCEOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISEDOF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Portions of this software are derived from code under the same license and
|
||||
|
||||
Copyright (c) 1998 - 2009, Paul Johnston & Contributors
|
||||
All rights reserved.
|
||||
|
||||
Original code is available on http://pajhome.org.uk/crypt/md5
|
||||
Generated
Vendored
+154
@@ -0,0 +1,154 @@
|
||||
# jsSHA
|
||||
A JavaScript implementation of the complete Secure Hash Standard family
|
||||
(SHA-1, SHA-224, SHA3-224, SHA-256, SHA3-256, SHA-384, SHA3-384, SHA-512,
|
||||
SHA3-512, SHAKE128, and SHAKE256) as well as HMAC by Brian Turek.
|
||||
|
||||
[](https://travis-ci.org/Caligatio/jsSHA)
|
||||
|
||||
## About
|
||||
jsSHA is a javaScript implementation of the complete Secure Hash Algorithm
|
||||
family as defined by
|
||||
[FIPS PUB 180-4](http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) and
|
||||
[FIPS PUB 202](http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf). It also
|
||||
includes the HMAC algorithm with SHA support as defined by
|
||||
[FIPS PUB 198-1](http://csrc.nist.gov/publications/fips/fips198-1/FIPS-198-1_final.pdf).
|
||||
|
||||
## Files
|
||||
**src/sha\_dev.js**
|
||||
|
||||
A commented implementation of the entire SHA family of hashes. Not to be used
|
||||
in production.
|
||||
|
||||
**src/sha.js**
|
||||
|
||||
A Google Closure Compiler optimized version of the entire library.
|
||||
|
||||
**src/sha1.js**
|
||||
|
||||
A Google Closure Compiler optimized version the library with non SHA-1
|
||||
functionality removed.
|
||||
|
||||
**src/sha256.js**
|
||||
|
||||
A Google Closure Compiler optimized version the library with non SHA-224/SHA-256
|
||||
functionality removed.
|
||||
|
||||
**src/sha3.js**
|
||||
|
||||
A Google Closure Compiler optimized version the library with non SHA-3
|
||||
functionality removed.
|
||||
|
||||
**src/sha512.js**
|
||||
|
||||
A Google Closure Compiler optimized version the library with non SHA-384/SHA-512
|
||||
functionality removed.
|
||||
|
||||
**test/test.html**
|
||||
|
||||
Mocha/Chai test page that runs all the tests.
|
||||
|
||||
**test/genHashRounds.py**
|
||||
|
||||
A Python2 script that generates multi-round hash values.
|
||||
|
||||
**test/genShake.py**
|
||||
|
||||
A Python2 script that generates SHAKE hash values.
|
||||
|
||||
**test/sha3.py**
|
||||
|
||||
A Python reference implementation of the SHA3 family of hashes.
|
||||
|
||||
**build/make-release**
|
||||
|
||||
A Bash script that runs the various Google Closure Compiler commands to build
|
||||
a release.
|
||||
|
||||
**build/externs.js**
|
||||
|
||||
File needed solely to make the Google Closure Compilter work.
|
||||
|
||||
## Usage
|
||||
|
||||
### Browser
|
||||
Include the desired JavaScript file (sha.js, sha1.js, sha256.js, sha512.js, or
|
||||
sha3.js) in your header (sha.js used below):
|
||||
|
||||
<script type="text/javascript" src="/path/to/sha.js"></script>
|
||||
|
||||
#### Hashing
|
||||
Instantiate a new jsSHA object with the desired hash type, input type, and
|
||||
options as parameters. The hash type can be one of SHA-1, SHA-224, SHA3-224,
|
||||
SHA-256, SHA3-256, SHA-384, SHA3-384, SHA-512, SHA3-512, SHAKE128, or SHAKE256.
|
||||
The input type can be one of HEX, TEXT, B64, BYTES, or ARRAYBUFFER. You can
|
||||
then stream in input using the `update` object function. Finally, simply call
|
||||
`getHash` with the output type as a parameter (B64, HEX, BYTES, or ARRAYBUFFER).
|
||||
Example to calculate the SHA-512 of "This is a test":
|
||||
|
||||
var shaObj = new jsSHA("SHA-512", "TEXT");
|
||||
shaObj.update("This is a test");
|
||||
var hash = shaObj.getHash("HEX");
|
||||
|
||||
The constructor takes a hashmap as a optional third argument with possible
|
||||
properties of `numRounds` and `encoding`. `numRounds` controls the number of
|
||||
hashing iterations/rounds performed and defaults to a value of 1 if not
|
||||
specified. `encoding` specifies the encoding used to encode TEXT-type inputs.
|
||||
Valid options are "UTF8", "UTF16BE", and "UTF16LE", it defaults to "UTF8".
|
||||
|
||||
`getHash` also takes a hashmap as an optional second argument. By default the
|
||||
hashmap is `{"outputUpper" : false, "b64Pad" : "="}`. These options are
|
||||
intelligently interpreted based upon the chosen output format. **Important**:
|
||||
SHAKE128 and SHAKE256 require `shakeLen` to be included in the hashmap where
|
||||
`shakeLen` is the desired output length of the SHAKE algorithm in a multiple
|
||||
of 8 bits.
|
||||
|
||||
#### HMAC
|
||||
Instantiate a new jsSHA object the same way as for hashing. Then set the HMAC
|
||||
key to be used by calling `setHMACKey` with the key and its input type (this
|
||||
MUST be done before calling update). You can stream in the input using the
|
||||
`update` object function just like hashing. Finally, get the HMAC by calling
|
||||
the `getHMAC` function with the output type as its argument. Example to
|
||||
calculate the SHA-512 HMAC of the string "This is a test" with the key "abc":
|
||||
|
||||
var shaObj = new jsSHA(hashType, "TEXT");
|
||||
shaObj.setHMACKey("abc", "TEXT");
|
||||
shaObj.update("This is a test");
|
||||
var hmac = shaObj.getHMAC("HEX");
|
||||
|
||||
`setHMACKey` takes the same input types as the constructor and `getHMAC` takes the
|
||||
same inputs as `getHash` as described above.
|
||||
|
||||
Note: You cannot calculate both the hash and HMAC using the same object.
|
||||
|
||||
### Node.js
|
||||
jsSHA is available through NPM and be installed by simply doing
|
||||
|
||||
npm install jssha
|
||||
To use the module, first require it using:
|
||||
|
||||
jsSHA = require("jssha");
|
||||
|
||||
The rest of the instructions are identical to the [Browser](#browser) section above.
|
||||
|
||||
## Compiling
|
||||
This library makes use of the [Google Closure Compiler](https://developers.google.com/closure/compiler)
|
||||
to both boost performance and reduce filesizes. To compile sha\_dev.js into a customized output file,
|
||||
use a command like the following:
|
||||
|
||||
java -jar compiler.jar --define="SUPPORTED_ALGS=<FLAG>" \
|
||||
--externs /path/to/build/externs.js --warning_level VERBOSE \
|
||||
--compilation_level ADVANCED_OPTIMIZATIONS \
|
||||
--js /path/to/sha_dev.js --js_output_file /path/to/sha.js
|
||||
|
||||
where FLAG is a bitwise OR of the following values:
|
||||
|
||||
* 8 for SHA3
|
||||
* 4 for SHA-384/SHA-512
|
||||
* 2 for SHA-224/256
|
||||
* 1 for SHA-1
|
||||
|
||||
## Contact Info
|
||||
The project's website is located at [http://caligatio.github.com/jsSHA/](http://caligatio.github.com/jsSHA/)
|
||||
|
||||
## Donations
|
||||
Feel like donating? We're now accepting donations [through Pledgie](https://pledgie.com/campaigns/31646)!
|
||||
Generated
Vendored
+51
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name" : "jsSHA",
|
||||
"version" : "2.2.0",
|
||||
"description" : "jsSHA is a JavaScript implementation of the complete Secure Hash Standard family (SHA-1, SHA-224, SHA3-224, SHA-256, SHA3-256, SHA-384, SHA3-384, SHA-512, SHA3-512, SHAKE128, and SHAKE256) as well as HMAC",
|
||||
"main" : "src/sha.js",
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/Caligatio/jsSHA.git"
|
||||
},
|
||||
"keywords" : [
|
||||
"SHA-1",
|
||||
"SHA-224",
|
||||
"SHA3-224",
|
||||
"SHA-256",
|
||||
"SHA3-256",
|
||||
"SHA-384",
|
||||
"SHA3-384",
|
||||
"SHA-512",
|
||||
"SHA3-512",
|
||||
"SHAKE-128",
|
||||
"SHAKE-256",
|
||||
"SHAKE128",
|
||||
"SHAKE256",
|
||||
"SHA1",
|
||||
"SHA224",
|
||||
"SHA256",
|
||||
"SHA384",
|
||||
"SHA512",
|
||||
"SHA-2",
|
||||
"SHA2",
|
||||
"SHA-3",
|
||||
"SHA3",
|
||||
"SHAKE",
|
||||
"HMAC",
|
||||
"hash"
|
||||
],
|
||||
"license" : "BSD-3-Clause",
|
||||
"authors" : [
|
||||
"Brian Turek <brian.turek@gmail.com>"
|
||||
],
|
||||
"homepage" : "http://caligatio.github.com/jsSHA/",
|
||||
"ignore": [
|
||||
"build",
|
||||
"test",
|
||||
"src/sha_dev.js"
|
||||
],
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"mocha": "^2.5.3"
|
||||
}
|
||||
}
|
||||
_platforms/browser/platform_www/plugins/cordova-plugin-mfp/worklight/node_modules/jssha/package.json
Generated
Vendored
+88
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"jssha@2.2.0",
|
||||
"C:\\Users\\tiago.kayaya\\development\\gabinete-digital"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "jssha@2.2.0",
|
||||
"_id": "jssha@2.2.0",
|
||||
"_inBundle": true,
|
||||
"_integrity": "sha1-h9z2CCHcO+xZPzhVu+vM0naqzBw=",
|
||||
"_location": "/cordova-plugin-mfp/jssha",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "jssha@2.2.0",
|
||||
"name": "jssha",
|
||||
"escapedName": "jssha",
|
||||
"rawSpec": "2.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cordova-plugin-mfp"
|
||||
],
|
||||
"_resolved": false,
|
||||
"_shasum": "87dcf60821dc3bec593f3855bbebccd276aacc1c",
|
||||
"_spec": "2.2.0",
|
||||
"_where": "C:\\Users\\tiago.kayaya\\development\\gabinete-digital",
|
||||
"author": {
|
||||
"name": "Brian Turek",
|
||||
"email": "brian.turek@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Caligatio/jsSHA/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "jsSHA is a JavaScript implementation of the complete Secure Hash Standard family (SHA-1, SHA-224, SHA3-224, SHA-256, SHA3-256, SHA-384, SHA3-384, SHA-512, SHA3-512, SHAKE128, and SHAKE256) as well as HMAC",
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"mocha": "^2.5.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/Caligatio/jsSHA",
|
||||
"keywords": [
|
||||
"SHA-1",
|
||||
"SHA-224",
|
||||
"SHA3-224",
|
||||
"SHA-256",
|
||||
"SHA3-256",
|
||||
"SHA-384",
|
||||
"SHA3-384",
|
||||
"SHA-512",
|
||||
"SHA3-512",
|
||||
"SHAKE-128",
|
||||
"SHAKE-256",
|
||||
"SHAKE128",
|
||||
"SHAKE256",
|
||||
"SHA1",
|
||||
"SHA224",
|
||||
"SHA256",
|
||||
"SHA384",
|
||||
"SHA512",
|
||||
"SHA-2",
|
||||
"SHA2",
|
||||
"SHA-3",
|
||||
"SHA3",
|
||||
"SHAKE",
|
||||
"HMAC",
|
||||
"hash"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "src/sha.js",
|
||||
"name": "jssha",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Caligatio/jsSHA.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec"
|
||||
},
|
||||
"version": "2.2.0"
|
||||
}
|
||||
Generated
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
A JavaScript implementation of the SHA family of hashes, as
|
||||
defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding
|
||||
HMAC implementation as defined in FIPS PUB 198a
|
||||
|
||||
Copyright Brian Turek 2008-2016
|
||||
Distributed under the BSD License
|
||||
See http://caligatio.github.com/jsSHA/ for more information
|
||||
|
||||
Several functions taken from Paul Johnston
|
||||
*/
|
||||
'use strict';(function(X){function C(f,b,c){var d=0,a=[],k=0,g,e,n,h,m,r,t,q,v=!1,u=[],w=[],x,y=!1,z=!1;c=c||{};g=c.encoding||"UTF8";x=c.numRounds||1;n=J(b,g);if(x!==parseInt(x,10)||1>x)throw Error("numRounds must a integer >= 1");if("SHA-1"===f)m=512,r=K,t=Y,h=160,q=function(b){return b.slice()};else if(0===f.lastIndexOf("SHA-",0))if(r=function(b,d){return L(b,d,f)},t=function(b,d,c,a){var l,k;if("SHA-224"===f||"SHA-256"===f)l=(d+65>>>9<<4)+15,k=16;else if("SHA-384"===f||"SHA-512"===f)l=(d+129>>>
|
||||
10<<5)+31,k=32;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=l;)b.push(0);b[d>>>5]|=128<<24-d%32;d=d+c;b[l]=d&4294967295;b[l-1]=d/4294967296|0;c=b.length;for(d=0;d<c;d+=k)a=L(b.slice(d,d+k),a,f);if("SHA-224"===f)b=[a[0],a[1],a[2],a[3],a[4],a[5],a[6]];else if("SHA-256"===f)b=a;else if("SHA-384"===f)b=[a[0].a,a[0].b,a[1].a,a[1].b,a[2].a,a[2].b,a[3].a,a[3].b,a[4].a,a[4].b,a[5].a,a[5].b];else if("SHA-512"===f)b=[a[0].a,a[0].b,a[1].a,a[1].b,a[2].a,a[2].b,a[3].a,a[3].b,a[4].a,
|
||||
a[4].b,a[5].a,a[5].b,a[6].a,a[6].b,a[7].a,a[7].b];else throw Error("Unexpected error in SHA-2 implementation");return b},q=function(b){return b.slice()},"SHA-224"===f)m=512,h=224;else if("SHA-256"===f)m=512,h=256;else if("SHA-384"===f)m=1024,h=384;else if("SHA-512"===f)m=1024,h=512;else throw Error("Chosen SHA variant is not supported");else if(0===f.lastIndexOf("SHA3-",0)||0===f.lastIndexOf("SHAKE",0)){var F=6;r=D;q=function(b){var f=[],a;for(a=0;5>a;a+=1)f[a]=b[a].slice();return f};if("SHA3-224"===
|
||||
f)m=1152,h=224;else if("SHA3-256"===f)m=1088,h=256;else if("SHA3-384"===f)m=832,h=384;else if("SHA3-512"===f)m=576,h=512;else if("SHAKE128"===f)m=1344,h=-1,F=31,z=!0;else if("SHAKE256"===f)m=1088,h=-1,F=31,z=!0;else throw Error("Chosen SHA variant is not supported");t=function(b,f,a,d,c){a=m;var l=F,k,g=[],e=a>>>5,h=0,p=f>>>5;for(k=0;k<p&&f>=a;k+=e)d=D(b.slice(k,k+e),d),f-=a;b=b.slice(k);for(f%=a;b.length<e;)b.push(0);k=f>>>3;b[k>>2]^=l<<24-k%4*8;b[e-1]^=128;for(d=D(b,d);32*g.length<c;){b=d[h%5][h/
|
||||
5|0];g.push((b.b&255)<<24|(b.b&65280)<<8|(b.b&16711680)>>8|b.b>>>24);if(32*g.length>=c)break;g.push((b.a&255)<<24|(b.a&65280)<<8|(b.a&16711680)>>8|b.a>>>24);h+=1;0===64*h%a&&D(null,d)}return g}}else throw Error("Chosen SHA variant is not supported");e=B(f);this.setHMACKey=function(b,a,c){var l;if(!0===v)throw Error("HMAC key already set");if(!0===y)throw Error("Cannot set HMAC key after calling update");if(!0===z)throw Error("SHAKE is not supported for HMAC");g=(c||{}).encoding||"UTF8";a=J(a,g)(b);
|
||||
b=a.binLen;a=a.value;l=m>>>3;c=l/4-1;if(l<b/8){for(a=t(a,b,0,B(f),h);a.length<=c;)a.push(0);a[c]&=4294967040}else if(l>b/8){for(;a.length<=c;)a.push(0);a[c]&=4294967040}for(b=0;b<=c;b+=1)u[b]=a[b]^909522486,w[b]=a[b]^1549556828;e=r(u,e);d=m;v=!0};this.update=function(b){var f,c,g,h=0,q=m>>>5;f=n(b,a,k);b=f.binLen;c=f.value;f=b>>>5;for(g=0;g<f;g+=q)h+m<=b&&(e=r(c.slice(g,g+q),e),h+=m);d+=h;a=c.slice(h>>>5);k=b%m;y=!0};this.getHash=function(b,c){var g,m,n,r;if(!0===v)throw Error("Cannot call getHash after setting HMAC key");
|
||||
n=M(c);if(!0===z){if(-1===n.shakeLen)throw Error("shakeLen must be specified in options");h=n.shakeLen}switch(b){case "HEX":g=function(b){return N(b,h,n)};break;case "B64":g=function(b){return O(b,h,n)};break;case "BYTES":g=function(b){return P(b,h)};break;case "ARRAYBUFFER":try{m=new ArrayBuffer(0)}catch(sa){throw Error("ARRAYBUFFER not supported by this environment");}g=function(b){return Q(b,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");}r=t(a.slice(),k,d,q(e),
|
||||
h);for(m=1;m<x;m+=1)!0===z&&0!==h%32&&(r[r.length-1]&=4294967040<<24-h%32),r=t(r,h,0,B(f),h);return g(r)};this.getHMAC=function(b,c){var g,n,u,x;if(!1===v)throw Error("Cannot call getHMAC without first setting HMAC key");u=M(c);switch(b){case "HEX":g=function(b){return N(b,h,u)};break;case "B64":g=function(b){return O(b,h,u)};break;case "BYTES":g=function(b){return P(b,h)};break;case "ARRAYBUFFER":try{g=new ArrayBuffer(0)}catch(z){throw Error("ARRAYBUFFER not supported by this environment");}g=function(b){return Q(b,
|
||||
h)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER");}n=t(a.slice(),k,d,q(e),h);x=r(w,B(f));x=t(n,h,m,x,h);return g(x)}}function a(f,b){this.a=f;this.b=b}function Z(f,b,a){var d=f.length,l,k,g,e,n;b=b||[0];a=a||0;n=a>>>3;if(0!==d%2)throw Error("String of HEX type must be in byte increments");for(l=0;l<d;l+=2){k=parseInt(f.substr(l,2),16);if(isNaN(k))throw Error("String of HEX type contains invalid characters");e=(l>>>1)+n;for(g=e>>>2;b.length<=g;)b.push(0);b[g]|=k<<
|
||||
8*(3-e%4)}return{value:b,binLen:4*d+a}}function aa(f,b,a){var d=[],l,k,g,e,d=b||[0];a=a||0;k=a>>>3;for(l=0;l<f.length;l+=1)b=f.charCodeAt(l),e=l+k,g=e>>>2,d.length<=g&&d.push(0),d[g]|=b<<8*(3-e%4);return{value:d,binLen:8*f.length+a}}function ba(f,b,a){var d=[],l=0,k,g,e,n,h,m,d=b||[0];a=a||0;b=a>>>3;if(-1===f.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");g=f.indexOf("=");f=f.replace(/\=/g,"");if(-1!==g&&g<f.length)throw Error("Invalid '=' found in base-64 string");
|
||||
for(g=0;g<f.length;g+=4){h=f.substr(g,4);for(e=n=0;e<h.length;e+=1)k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(h[e]),n|=k<<18-6*e;for(e=0;e<h.length-1;e+=1){m=l+b;for(k=m>>>2;d.length<=k;)d.push(0);d[k]|=(n>>>16-8*e&255)<<8*(3-m%4);l+=1}}return{value:d,binLen:8*l+a}}function ca(a,b,c){var d=[],l,k,g,d=b||[0];c=c||0;l=c>>>3;for(b=0;b<a.byteLength;b+=1)g=b+l,k=g>>>2,d.length<=k&&d.push(0),d[k]|=a[b]<<8*(3-g%4);return{value:d,binLen:8*a.byteLength+c}}function N(a,b,c){var d=
|
||||
"";b/=8;var l,k;for(l=0;l<b;l+=1)k=a[l>>>2]>>>8*(3-l%4),d+="0123456789abcdef".charAt(k>>>4&15)+"0123456789abcdef".charAt(k&15);return c.outputUpper?d.toUpperCase():d}function O(a,b,c){var d="",l=b/8,k,g,e;for(k=0;k<l;k+=3)for(g=k+1<l?a[k+1>>>2]:0,e=k+2<l?a[k+2>>>2]:0,e=(a[k>>>2]>>>8*(3-k%4)&255)<<16|(g>>>8*(3-(k+1)%4)&255)<<8|e>>>8*(3-(k+2)%4)&255,g=0;4>g;g+=1)8*k+6*g<=b?d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e>>>6*(3-g)&63):d+=c.b64Pad;return d}function P(a,
|
||||
b){var c="",d=b/8,l,k;for(l=0;l<d;l+=1)k=a[l>>>2]>>>8*(3-l%4)&255,c+=String.fromCharCode(k);return c}function Q(a,b){var c=b/8,d,l=new ArrayBuffer(c);for(d=0;d<c;d+=1)l[d]=a[d>>>2]>>>8*(3-d%4)&255;return l}function M(a){var b={outputUpper:!1,b64Pad:"=",shakeLen:-1};a=a||{};b.outputUpper=a.outputUpper||!1;!0===a.hasOwnProperty("b64Pad")&&(b.b64Pad=a.b64Pad);if(!0===a.hasOwnProperty("shakeLen")){if(0!==a.shakeLen%8)throw Error("shakeLen must be a multiple of 8");b.shakeLen=a.shakeLen}if("boolean"!==
|
||||
typeof b.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof b.b64Pad)throw Error("Invalid b64Pad formatting option");return b}function J(a,b){var c;switch(b){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(a){case "HEX":c=Z;break;case "TEXT":c=function(a,f,c){var e=[],p=[],n=0,h,m,r,t,q,e=f||[0];f=c||0;r=f>>>3;if("UTF8"===b)for(h=0;h<a.length;h+=1)for(c=a.charCodeAt(h),p=[],128>c?p.push(c):
|
||||
2048>c?(p.push(192|c>>>6),p.push(128|c&63)):55296>c||57344<=c?p.push(224|c>>>12,128|c>>>6&63,128|c&63):(h+=1,c=65536+((c&1023)<<10|a.charCodeAt(h)&1023),p.push(240|c>>>18,128|c>>>12&63,128|c>>>6&63,128|c&63)),m=0;m<p.length;m+=1){q=n+r;for(t=q>>>2;e.length<=t;)e.push(0);e[t]|=p[m]<<8*(3-q%4);n+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(h=0;h<a.length;h+=1){c=a.charCodeAt(h);"UTF16LE"===b&&(m=c&255,c=m<<8|c>>>8);q=n+r;for(t=q>>>2;e.length<=t;)e.push(0);e[t]|=c<<8*(2-q%4);n+=2}return{value:e,binLen:8*
|
||||
n+f}};break;case "B64":c=ba;break;case "BYTES":c=aa;break;case "ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(d){throw Error("ARRAYBUFFER not supported by this environment");}c=ca;break;default:throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER");}return c}function y(a,b){return a<<b|a>>>32-b}function R(f,b){return 32<b?(b=b-32,new a(f.b<<b|f.a>>>32-b,f.a<<b|f.b>>>32-b)):0!==b?new a(f.a<<b|f.b>>>32-b,f.b<<b|f.a>>>32-b):f}function v(a,b){return a>>>b|a<<32-b}function w(f,b){var c=null,
|
||||
c=new a(f.a,f.b);return c=32>=b?new a(c.a>>>b|c.b<<32-b&4294967295,c.b>>>b|c.a<<32-b&4294967295):new a(c.b>>>b-32|c.a<<64-b&4294967295,c.a>>>b-32|c.b<<64-b&4294967295)}function S(f,b){var c=null;return c=32>=b?new a(f.a>>>b,f.b>>>b|f.a<<32-b&4294967295):new a(0,f.a>>>b-32)}function da(a,b,c){return a&b^~a&c}function ea(f,b,c){return new a(f.a&b.a^~f.a&c.a,f.b&b.b^~f.b&c.b)}function T(a,b,c){return a&b^a&c^b&c}function fa(f,b,c){return new a(f.a&b.a^f.a&c.a^b.a&c.a,f.b&b.b^f.b&c.b^b.b&c.b)}function ga(a){return v(a,
|
||||
2)^v(a,13)^v(a,22)}function ha(f){var b=w(f,28),c=w(f,34);f=w(f,39);return new a(b.a^c.a^f.a,b.b^c.b^f.b)}function ia(a){return v(a,6)^v(a,11)^v(a,25)}function ja(f){var b=w(f,14),c=w(f,18);f=w(f,41);return new a(b.a^c.a^f.a,b.b^c.b^f.b)}function ka(a){return v(a,7)^v(a,18)^a>>>3}function la(f){var b=w(f,1),c=w(f,8);f=S(f,7);return new a(b.a^c.a^f.a,b.b^c.b^f.b)}function ma(a){return v(a,17)^v(a,19)^a>>>10}function na(f){var b=w(f,19),c=w(f,61);f=S(f,6);return new a(b.a^c.a^f.a,b.b^c.b^f.b)}function G(a,
|
||||
b){var c=(a&65535)+(b&65535);return((a>>>16)+(b>>>16)+(c>>>16)&65535)<<16|c&65535}function oa(a,b,c,d){var l=(a&65535)+(b&65535)+(c&65535)+(d&65535);return((a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(l>>>16)&65535)<<16|l&65535}function H(a,b,c,d,l){var e=(a&65535)+(b&65535)+(c&65535)+(d&65535)+(l&65535);return((a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(l>>>16)+(e>>>16)&65535)<<16|e&65535}function pa(f,b){var c,d,l;c=(f.b&65535)+(b.b&65535);d=(f.b>>>16)+(b.b>>>16)+(c>>>16);l=(d&65535)<<16|c&65535;c=(f.a&65535)+
|
||||
(b.a&65535)+(d>>>16);d=(f.a>>>16)+(b.a>>>16)+(c>>>16);return new a((d&65535)<<16|c&65535,l)}function qa(f,b,c,d){var l,e,g;l=(f.b&65535)+(b.b&65535)+(c.b&65535)+(d.b&65535);e=(f.b>>>16)+(b.b>>>16)+(c.b>>>16)+(d.b>>>16)+(l>>>16);g=(e&65535)<<16|l&65535;l=(f.a&65535)+(b.a&65535)+(c.a&65535)+(d.a&65535)+(e>>>16);e=(f.a>>>16)+(b.a>>>16)+(c.a>>>16)+(d.a>>>16)+(l>>>16);return new a((e&65535)<<16|l&65535,g)}function ra(f,b,c,d,l){var e,g,p;e=(f.b&65535)+(b.b&65535)+(c.b&65535)+(d.b&65535)+(l.b&65535);g=
|
||||
(f.b>>>16)+(b.b>>>16)+(c.b>>>16)+(d.b>>>16)+(l.b>>>16)+(e>>>16);p=(g&65535)<<16|e&65535;e=(f.a&65535)+(b.a&65535)+(c.a&65535)+(d.a&65535)+(l.a&65535)+(g>>>16);g=(f.a>>>16)+(b.a>>>16)+(c.a>>>16)+(d.a>>>16)+(l.a>>>16)+(e>>>16);return new a((g&65535)<<16|e&65535,p)}function A(f){var b=0,c=0,d;for(d=0;d<arguments.length;d+=1)b^=arguments[d].b,c^=arguments[d].a;return new a(c,b)}function B(f){var b=[],c;if("SHA-1"===f)b=[1732584193,4023233417,2562383102,271733878,3285377520];else if(0===f.lastIndexOf("SHA-",
|
||||
0))switch(b=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],c=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],f){case "SHA-224":break;case "SHA-256":b=c;break;case "SHA-384":b=[new a(3418070365,b[0]),new a(1654270250,b[1]),new a(2438529370,b[2]),new a(355462360,b[3]),new a(1731405415,b[4]),new a(41048885895,b[5]),new a(3675008525,b[6]),new a(1203062813,b[7])];break;case "SHA-512":b=[new a(c[0],4089235720),new a(c[1],
|
||||
2227873595),new a(c[2],4271175723),new a(c[3],1595750129),new a(c[4],2917565137),new a(c[5],725511199),new a(c[6],4215389547),new a(c[7],327033209)];break;default:throw Error("Unknown SHA variant");}else if(0===f.lastIndexOf("SHA3-",0)||0===f.lastIndexOf("SHAKE",0))for(f=0;5>f;f+=1)b[f]=[new a(0,0),new a(0,0),new a(0,0),new a(0,0),new a(0,0)];else throw Error("No SHA variants supported");return b}function K(a,b){var c=[],d,e,k,g,p,n,h;d=b[0];e=b[1];k=b[2];g=b[3];p=b[4];for(h=0;80>h;h+=1)c[h]=16>h?
|
||||
a[h]:y(c[h-3]^c[h-8]^c[h-14]^c[h-16],1),n=20>h?H(y(d,5),e&k^~e&g,p,1518500249,c[h]):40>h?H(y(d,5),e^k^g,p,1859775393,c[h]):60>h?H(y(d,5),T(e,k,g),p,2400959708,c[h]):H(y(d,5),e^k^g,p,3395469782,c[h]),p=g,g=k,k=y(e,30),e=d,d=n;b[0]=G(d,b[0]);b[1]=G(e,b[1]);b[2]=G(k,b[2]);b[3]=G(g,b[3]);b[4]=G(p,b[4]);return b}function Y(a,b,c,d){var e;for(e=(b+65>>>9<<4)+15;a.length<=e;)a.push(0);a[b>>>5]|=128<<24-b%32;b+=c;a[e]=b&4294967295;a[e-1]=b/4294967296|0;b=a.length;for(e=0;e<b;e+=16)d=K(a.slice(e,e+16),d);
|
||||
return d}function L(f,b,c){var d,l,k,g,p,n,h,m,r,t,q,v,u,w,x,y,z,F,A,B,C,D,E=[],I;if("SHA-224"===c||"SHA-256"===c)t=64,v=1,D=Number,u=G,w=oa,x=H,y=ka,z=ma,F=ga,A=ia,C=T,B=da,I=e;else if("SHA-384"===c||"SHA-512"===c)t=80,v=2,D=a,u=pa,w=qa,x=ra,y=la,z=na,F=ha,A=ja,C=fa,B=ea,I=U;else throw Error("Unexpected error in SHA-2 implementation");c=b[0];d=b[1];l=b[2];k=b[3];g=b[4];p=b[5];n=b[6];h=b[7];for(q=0;q<t;q+=1)16>q?(r=q*v,m=f.length<=r?0:f[r],r=f.length<=r+1?0:f[r+1],E[q]=new D(m,r)):E[q]=w(z(E[q-2]),
|
||||
E[q-7],y(E[q-15]),E[q-16]),m=x(h,A(g),B(g,p,n),I[q],E[q]),r=u(F(c),C(c,d,l)),h=n,n=p,p=g,g=u(k,m),k=l,l=d,d=c,c=u(m,r);b[0]=u(c,b[0]);b[1]=u(d,b[1]);b[2]=u(l,b[2]);b[3]=u(k,b[3]);b[4]=u(g,b[4]);b[5]=u(p,b[5]);b[6]=u(n,b[6]);b[7]=u(h,b[7]);return b}function D(f,b){var c,d,e,k,g=[],p=[];if(null!==f)for(d=0;d<f.length;d+=2)b[(d>>>1)%5][(d>>>1)/5|0]=A(b[(d>>>1)%5][(d>>>1)/5|0],new a((f[d+1]&255)<<24|(f[d+1]&65280)<<8|(f[d+1]&16711680)>>>8|f[d+1]>>>24,(f[d]&255)<<24|(f[d]&65280)<<8|(f[d]&16711680)>>>8|
|
||||
f[d]>>>24));for(c=0;24>c;c+=1){k=B("SHA3-");for(d=0;5>d;d+=1)g[d]=A(b[d][0],b[d][1],b[d][2],b[d][3],b[d][4]);for(d=0;5>d;d+=1)p[d]=A(g[(d+4)%5],R(g[(d+1)%5],1));for(d=0;5>d;d+=1)for(e=0;5>e;e+=1)b[d][e]=A(b[d][e],p[d]);for(d=0;5>d;d+=1)for(e=0;5>e;e+=1)k[e][(2*d+3*e)%5]=R(b[d][e],V[d][e]);for(d=0;5>d;d+=1)for(e=0;5>e;e+=1)b[d][e]=A(k[d][e],new a(~k[(d+1)%5][e].a&k[(d+2)%5][e].a,~k[(d+1)%5][e].b&k[(d+2)%5][e].b));b[0][0]=A(b[0][0],W[c])}return b}var e,U,V,W;e=[1116352408,1899447441,3049323471,3921009573,
|
||||
961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,
|
||||
883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];U=[new a(e[0],3609767458),new a(e[1],602891725),new a(e[2],3964484399),new a(e[3],2173295548),new a(e[4],4081628472),new a(e[5],3053834265),new a(e[6],2937671579),new a(e[7],3664609560),new a(e[8],2734883394),new a(e[9],1164996542),new a(e[10],1323610764),new a(e[11],3590304994),new a(e[12],4068182383),new a(e[13],991336113),new a(e[14],633803317),new a(e[15],
|
||||
3479774868),new a(e[16],2666613458),new a(e[17],944711139),new a(e[18],2341262773),new a(e[19],2007800933),new a(e[20],1495990901),new a(e[21],1856431235),new a(e[22],3175218132),new a(e[23],2198950837),new a(e[24],3999719339),new a(e[25],766784016),new a(e[26],2566594879),new a(e[27],3203337956),new a(e[28],1034457026),new a(e[29],2466948901),new a(e[30],3758326383),new a(e[31],168717936),new a(e[32],1188179964),new a(e[33],1546045734),new a(e[34],1522805485),new a(e[35],2643833823),new a(e[36],
|
||||
2343527390),new a(e[37],1014477480),new a(e[38],1206759142),new a(e[39],344077627),new a(e[40],1290863460),new a(e[41],3158454273),new a(e[42],3505952657),new a(e[43],106217008),new a(e[44],3606008344),new a(e[45],1432725776),new a(e[46],1467031594),new a(e[47],851169720),new a(e[48],3100823752),new a(e[49],1363258195),new a(e[50],3750685593),new a(e[51],3785050280),new a(e[52],3318307427),new a(e[53],3812723403),new a(e[54],2003034995),new a(e[55],3602036899),new a(e[56],1575990012),new a(e[57],
|
||||
1125592928),new a(e[58],2716904306),new a(e[59],442776044),new a(e[60],593698344),new a(e[61],3733110249),new a(e[62],2999351573),new a(e[63],3815920427),new a(3391569614,3928383900),new a(3515267271,566280711),new a(3940187606,3454069534),new a(4118630271,4000239992),new a(116418474,1914138554),new a(174292421,2731055270),new a(289380356,3203993006),new a(460393269,320620315),new a(685471733,587496836),new a(852142971,1086792851),new a(1017036298,365543100),new a(1126000580,2618297676),new a(1288033470,
|
||||
3409855158),new a(1501505948,4234509866),new a(1607167915,987167468),new a(1816402316,1246189591)];W=[new a(0,1),new a(0,32898),new a(2147483648,32906),new a(2147483648,2147516416),new a(0,32907),new a(0,2147483649),new a(2147483648,2147516545),new a(2147483648,32777),new a(0,138),new a(0,136),new a(0,2147516425),new a(0,2147483658),new a(0,2147516555),new a(2147483648,139),new a(2147483648,32905),new a(2147483648,32771),new a(2147483648,32770),new a(2147483648,128),new a(0,32778),new a(2147483648,
|
||||
2147483658),new a(2147483648,2147516545),new a(2147483648,32896),new a(0,2147483649),new a(2147483648,2147516424)];V=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];"function"===typeof define&&define.amd?define(function(){return C}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(module.exports=C),exports=C):X.jsSHA=C})(this);
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
A JavaScript implementation of the SHA family of hashes, as
|
||||
defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding
|
||||
HMAC implementation as defined in FIPS PUB 198a
|
||||
|
||||
Copyright Brian Turek 2008-2016
|
||||
Distributed under the BSD License
|
||||
See http://caligatio.github.com/jsSHA/ for more information
|
||||
|
||||
Several functions taken from Paul Johnston
|
||||
*/
|
||||
'use strict';(function(G){function t(e,a,d){var g=0,c=[],b=0,f,k,l,h,m,w,n,y,p=!1,q=[],t=[],v,u=!1;d=d||{};f=d.encoding||"UTF8";v=d.numRounds||1;l=z(a,f);if(v!==parseInt(v,10)||1>v)throw Error("numRounds must a integer >= 1");if("SHA-1"===e)m=512,w=A,n=H,h=160,y=function(a){return a.slice()};else throw Error("Chosen SHA variant is not supported");k=x(e);this.setHMACKey=function(a,b,c){var d;if(!0===p)throw Error("HMAC key already set");if(!0===u)throw Error("Cannot set HMAC key after calling update");
|
||||
f=(c||{}).encoding||"UTF8";b=z(b,f)(a);a=b.binLen;b=b.value;d=m>>>3;c=d/4-1;if(d<a/8){for(b=n(b,a,0,x(e),h);b.length<=c;)b.push(0);b[c]&=4294967040}else if(d>a/8){for(;b.length<=c;)b.push(0);b[c]&=4294967040}for(a=0;a<=c;a+=1)q[a]=b[a]^909522486,t[a]=b[a]^1549556828;k=w(q,k);g=m;p=!0};this.update=function(a){var d,e,f,h=0,n=m>>>5;d=l(a,c,b);a=d.binLen;e=d.value;d=a>>>5;for(f=0;f<d;f+=n)h+m<=a&&(k=w(e.slice(f,f+n),k),h+=m);g+=h;c=e.slice(h>>>5);b=a%m;u=!0};this.getHash=function(a,d){var f,l,m,r;if(!0===
|
||||
p)throw Error("Cannot call getHash after setting HMAC key");m=B(d);switch(a){case "HEX":f=function(a){return C(a,h,m)};break;case "B64":f=function(a){return D(a,h,m)};break;case "BYTES":f=function(a){return E(a,h)};break;case "ARRAYBUFFER":try{l=new ArrayBuffer(0)}catch(I){throw Error("ARRAYBUFFER not supported by this environment");}f=function(a){return F(a,h)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");}r=n(c.slice(),b,g,y(k),h);for(l=1;l<v;l+=1)r=n(r,h,0,x(e),h);
|
||||
return f(r)};this.getHMAC=function(a,d){var f,l,q,r;if(!1===p)throw Error("Cannot call getHMAC without first setting HMAC key");q=B(d);switch(a){case "HEX":f=function(a){return C(a,h,q)};break;case "B64":f=function(a){return D(a,h,q)};break;case "BYTES":f=function(a){return E(a,h)};break;case "ARRAYBUFFER":try{f=new ArrayBuffer(0)}catch(I){throw Error("ARRAYBUFFER not supported by this environment");}f=function(a){return F(a,h)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER");
|
||||
}l=n(c.slice(),b,g,y(k),h);r=w(t,x(e));r=n(l,h,m,r,h);return f(r)}}function J(e,a,d){var g=e.length,c,b,f,k,l;a=a||[0];d=d||0;l=d>>>3;if(0!==g%2)throw Error("String of HEX type must be in byte increments");for(c=0;c<g;c+=2){b=parseInt(e.substr(c,2),16);if(isNaN(b))throw Error("String of HEX type contains invalid characters");k=(c>>>1)+l;for(f=k>>>2;a.length<=f;)a.push(0);a[f]|=b<<8*(3-k%4)}return{value:a,binLen:4*g+d}}function K(e,a,d){var g=[],c,b,f,k,g=a||[0];d=d||0;b=d>>>3;for(c=0;c<e.length;c+=
|
||||
1)a=e.charCodeAt(c),k=c+b,f=k>>>2,g.length<=f&&g.push(0),g[f]|=a<<8*(3-k%4);return{value:g,binLen:8*e.length+d}}function L(e,a,d){var g=[],c=0,b,f,k,l,h,m,g=a||[0];d=d||0;a=d>>>3;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");f=e.indexOf("=");e=e.replace(/\=/g,"");if(-1!==f&&f<e.length)throw Error("Invalid '=' found in base-64 string");for(f=0;f<e.length;f+=4){h=e.substr(f,4);for(k=l=0;k<h.length;k+=1)b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(h[k]),
|
||||
l|=b<<18-6*k;for(k=0;k<h.length-1;k+=1){m=c+a;for(b=m>>>2;g.length<=b;)g.push(0);g[b]|=(l>>>16-8*k&255)<<8*(3-m%4);c+=1}}return{value:g,binLen:8*c+d}}function M(e,a,d){var g=[],c,b,f,g=a||[0];d=d||0;c=d>>>3;for(a=0;a<e.byteLength;a+=1)f=a+c,b=f>>>2,g.length<=b&&g.push(0),g[b]|=e[a]<<8*(3-f%4);return{value:g,binLen:8*e.byteLength+d}}function C(e,a,d){var g="";a/=8;var c,b;for(c=0;c<a;c+=1)b=e[c>>>2]>>>8*(3-c%4),g+="0123456789abcdef".charAt(b>>>4&15)+"0123456789abcdef".charAt(b&15);return d.outputUpper?
|
||||
g.toUpperCase():g}function D(e,a,d){var g="",c=a/8,b,f,k;for(b=0;b<c;b+=3)for(f=b+1<c?e[b+1>>>2]:0,k=b+2<c?e[b+2>>>2]:0,k=(e[b>>>2]>>>8*(3-b%4)&255)<<16|(f>>>8*(3-(b+1)%4)&255)<<8|k>>>8*(3-(b+2)%4)&255,f=0;4>f;f+=1)8*b+6*f<=a?g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(k>>>6*(3-f)&63):g+=d.b64Pad;return g}function E(e,a){var d="",g=a/8,c,b;for(c=0;c<g;c+=1)b=e[c>>>2]>>>8*(3-c%4)&255,d+=String.fromCharCode(b);return d}function F(e,a){var d=a/8,g,c=new ArrayBuffer(d);
|
||||
for(g=0;g<d;g+=1)c[g]=e[g>>>2]>>>8*(3-g%4)&255;return c}function B(e){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};e=e||{};a.outputUpper=e.outputUpper||!1;!0===e.hasOwnProperty("b64Pad")&&(a.b64Pad=e.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function z(e,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");
|
||||
}switch(e){case "HEX":d=J;break;case "TEXT":d=function(d,c,b){var f=[],e=[],l=0,h,m,q,n,p,f=c||[0];c=b||0;q=c>>>3;if("UTF8"===a)for(h=0;h<d.length;h+=1)for(b=d.charCodeAt(h),e=[],128>b?e.push(b):2048>b?(e.push(192|b>>>6),e.push(128|b&63)):55296>b||57344<=b?e.push(224|b>>>12,128|b>>>6&63,128|b&63):(h+=1,b=65536+((b&1023)<<10|d.charCodeAt(h)&1023),e.push(240|b>>>18,128|b>>>12&63,128|b>>>6&63,128|b&63)),m=0;m<e.length;m+=1){p=l+q;for(n=p>>>2;f.length<=n;)f.push(0);f[n]|=e[m]<<8*(3-p%4);l+=1}else if("UTF16BE"===
|
||||
a||"UTF16LE"===a)for(h=0;h<d.length;h+=1){b=d.charCodeAt(h);"UTF16LE"===a&&(m=b&255,b=m<<8|b>>>8);p=l+q;for(n=p>>>2;f.length<=n;)f.push(0);f[n]|=b<<8*(2-p%4);l+=2}return{value:f,binLen:8*l+c}};break;case "B64":d=L;break;case "BYTES":d=K;break;case "ARRAYBUFFER":try{d=new ArrayBuffer(0)}catch(g){throw Error("ARRAYBUFFER not supported by this environment");}d=M;break;default:throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER");}return d}function p(e,a){return e<<a|e>>>32-a}function q(e,
|
||||
a){var d=(e&65535)+(a&65535);return((e>>>16)+(a>>>16)+(d>>>16)&65535)<<16|d&65535}function u(e,a,d,g,c){var b=(e&65535)+(a&65535)+(d&65535)+(g&65535)+(c&65535);return((e>>>16)+(a>>>16)+(d>>>16)+(g>>>16)+(c>>>16)+(b>>>16)&65535)<<16|b&65535}function x(e){var a=[];if("SHA-1"===e)a=[1732584193,4023233417,2562383102,271733878,3285377520];else throw Error("No SHA variants supported");return a}function A(e,a){var d=[],g,c,b,f,k,l,h;g=a[0];c=a[1];b=a[2];f=a[3];k=a[4];for(h=0;80>h;h+=1)d[h]=16>h?e[h]:p(d[h-
|
||||
3]^d[h-8]^d[h-14]^d[h-16],1),l=20>h?u(p(g,5),c&b^~c&f,k,1518500249,d[h]):40>h?u(p(g,5),c^b^f,k,1859775393,d[h]):60>h?u(p(g,5),c&b^c&f^b&f,k,2400959708,d[h]):u(p(g,5),c^b^f,k,3395469782,d[h]),k=f,f=b,b=p(c,30),c=g,g=l;a[0]=q(g,a[0]);a[1]=q(c,a[1]);a[2]=q(b,a[2]);a[3]=q(f,a[3]);a[4]=q(k,a[4]);return a}function H(e,a,d,g){var c;for(c=(a+65>>>9<<4)+15;e.length<=c;)e.push(0);e[a>>>5]|=128<<24-a%32;a+=d;e[c]=a&4294967295;e[c-1]=a/4294967296|0;a=e.length;for(c=0;c<a;c+=16)g=A(e.slice(c,c+16),g);return g}
|
||||
"function"===typeof define&&define.amd?define(function(){return t}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(module.exports=t),exports=t):G.jsSHA=t})(this);
|
||||
Generated
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
A JavaScript implementation of the SHA family of hashes, as
|
||||
defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding
|
||||
HMAC implementation as defined in FIPS PUB 198a
|
||||
|
||||
Copyright Brian Turek 2008-2016
|
||||
Distributed under the BSD License
|
||||
See http://caligatio.github.com/jsSHA/ for more information
|
||||
|
||||
Several functions taken from Paul Johnston
|
||||
*/
|
||||
'use strict';(function(I){function w(c,a,d){var g=0,f=[],b=0,e,h,n,k,m,t,y,p,l=!1,q=[],r=[],u,z=!1;d=d||{};e=d.encoding||"UTF8";u=d.numRounds||1;n=A(a,e);if(u!==parseInt(u,10)||1>u)throw Error("numRounds must a integer >= 1");if(0===c.lastIndexOf("SHA-",0))if(t=function(a,b){return B(a,b,c)},y=function(a,b,g,d){var f,e;if("SHA-224"===c||"SHA-256"===c)f=(b+65>>>9<<4)+15,e=16;else throw Error("Unexpected error in SHA-2 implementation");for(;a.length<=f;)a.push(0);a[b>>>5]|=128<<24-b%32;b=b+g;a[f]=b&
|
||||
4294967295;a[f-1]=b/4294967296|0;g=a.length;for(b=0;b<g;b+=e)d=B(a.slice(b,b+e),d,c);if("SHA-224"===c)a=[d[0],d[1],d[2],d[3],d[4],d[5],d[6]];else if("SHA-256"===c)a=d;else throw Error("Unexpected error in SHA-2 implementation");return a},p=function(a){return a.slice()},"SHA-224"===c)m=512,k=224;else if("SHA-256"===c)m=512,k=256;else throw Error("Chosen SHA variant is not supported");else throw Error("Chosen SHA variant is not supported");h=x(c);this.setHMACKey=function(a,b,d){var f;if(!0===l)throw Error("HMAC key already set");
|
||||
if(!0===z)throw Error("Cannot set HMAC key after calling update");e=(d||{}).encoding||"UTF8";b=A(b,e)(a);a=b.binLen;b=b.value;f=m>>>3;d=f/4-1;if(f<a/8){for(b=y(b,a,0,x(c));b.length<=d;)b.push(0);b[d]&=4294967040}else if(f>a/8){for(;b.length<=d;)b.push(0);b[d]&=4294967040}for(a=0;a<=d;a+=1)q[a]=b[a]^909522486,r[a]=b[a]^1549556828;h=t(q,h);g=m;l=!0};this.update=function(a){var c,d,e,k=0,p=m>>>5;c=n(a,f,b);a=c.binLen;d=c.value;c=a>>>5;for(e=0;e<c;e+=p)k+m<=a&&(h=t(d.slice(e,e+p),h),k+=m);g+=k;f=d.slice(k>>>
|
||||
5);b=a%m;z=!0};this.getHash=function(a,d){var e,m,n,t;if(!0===l)throw Error("Cannot call getHash after setting HMAC key");n=C(d);switch(a){case "HEX":e=function(a){return D(a,k,n)};break;case "B64":e=function(a){return E(a,k,n)};break;case "BYTES":e=function(a){return F(a,k)};break;case "ARRAYBUFFER":try{m=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}e=function(a){return G(a,k)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");
|
||||
}t=y(f.slice(),b,g,p(h));for(m=1;m<u;m+=1)t=y(t,k,0,x(c));return e(t)};this.getHMAC=function(a,d){var e,n,q,u;if(!1===l)throw Error("Cannot call getHMAC without first setting HMAC key");q=C(d);switch(a){case "HEX":e=function(a){return D(a,k,q)};break;case "B64":e=function(a){return E(a,k,q)};break;case "BYTES":e=function(a){return F(a,k)};break;case "ARRAYBUFFER":try{e=new ArrayBuffer(0)}catch(v){throw Error("ARRAYBUFFER not supported by this environment");}e=function(a){return G(a,k)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER");
|
||||
}n=y(f.slice(),b,g,p(h));u=t(r,x(c));u=y(n,k,m,u);return e(u)}}function l(){}function J(c,a,d){var g=c.length,f,b,e,h,n;a=a||[0];d=d||0;n=d>>>3;if(0!==g%2)throw Error("String of HEX type must be in byte increments");for(f=0;f<g;f+=2){b=parseInt(c.substr(f,2),16);if(isNaN(b))throw Error("String of HEX type contains invalid characters");h=(f>>>1)+n;for(e=h>>>2;a.length<=e;)a.push(0);a[e]|=b<<8*(3-h%4)}return{value:a,binLen:4*g+d}}function K(c,a,d){var g=[],f,b,e,h,g=a||[0];d=d||0;b=d>>>3;for(f=0;f<
|
||||
c.length;f+=1)a=c.charCodeAt(f),h=f+b,e=h>>>2,g.length<=e&&g.push(0),g[e]|=a<<8*(3-h%4);return{value:g,binLen:8*c.length+d}}function L(c,a,d){var g=[],f=0,b,e,h,n,k,m,g=a||[0];d=d||0;a=d>>>3;if(-1===c.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");e=c.indexOf("=");c=c.replace(/\=/g,"");if(-1!==e&&e<c.length)throw Error("Invalid '=' found in base-64 string");for(e=0;e<c.length;e+=4){k=c.substr(e,4);for(h=n=0;h<k.length;h+=1)b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(k[h]),
|
||||
n|=b<<18-6*h;for(h=0;h<k.length-1;h+=1){m=f+a;for(b=m>>>2;g.length<=b;)g.push(0);g[b]|=(n>>>16-8*h&255)<<8*(3-m%4);f+=1}}return{value:g,binLen:8*f+d}}function M(c,a,d){var g=[],f,b,e,g=a||[0];d=d||0;f=d>>>3;for(a=0;a<c.byteLength;a+=1)e=a+f,b=e>>>2,g.length<=b&&g.push(0),g[b]|=c[a]<<8*(3-e%4);return{value:g,binLen:8*c.byteLength+d}}function D(c,a,d){var g="";a/=8;var f,b;for(f=0;f<a;f+=1)b=c[f>>>2]>>>8*(3-f%4),g+="0123456789abcdef".charAt(b>>>4&15)+"0123456789abcdef".charAt(b&15);return d.outputUpper?
|
||||
g.toUpperCase():g}function E(c,a,d){var g="",f=a/8,b,e,h;for(b=0;b<f;b+=3)for(e=b+1<f?c[b+1>>>2]:0,h=b+2<f?c[b+2>>>2]:0,h=(c[b>>>2]>>>8*(3-b%4)&255)<<16|(e>>>8*(3-(b+1)%4)&255)<<8|h>>>8*(3-(b+2)%4)&255,e=0;4>e;e+=1)8*b+6*e<=a?g+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(h>>>6*(3-e)&63):g+=d.b64Pad;return g}function F(c,a){var d="",g=a/8,f,b;for(f=0;f<g;f+=1)b=c[f>>>2]>>>8*(3-f%4)&255,d+=String.fromCharCode(b);return d}function G(c,a){var d=a/8,g,f=new ArrayBuffer(d);
|
||||
for(g=0;g<d;g+=1)f[g]=c[g>>>2]>>>8*(3-g%4)&255;return f}function C(c){var a={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};a.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(a.b64Pad=c.b64Pad);if("boolean"!==typeof a.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof a.b64Pad)throw Error("Invalid b64Pad formatting option");return a}function A(c,a){var d;switch(a){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");
|
||||
}switch(c){case "HEX":d=J;break;case "TEXT":d=function(c,d,b){var e=[],h=[],n=0,k,m,t,l,p,e=d||[0];d=b||0;t=d>>>3;if("UTF8"===a)for(k=0;k<c.length;k+=1)for(b=c.charCodeAt(k),h=[],128>b?h.push(b):2048>b?(h.push(192|b>>>6),h.push(128|b&63)):55296>b||57344<=b?h.push(224|b>>>12,128|b>>>6&63,128|b&63):(k+=1,b=65536+((b&1023)<<10|c.charCodeAt(k)&1023),h.push(240|b>>>18,128|b>>>12&63,128|b>>>6&63,128|b&63)),m=0;m<h.length;m+=1){p=n+t;for(l=p>>>2;e.length<=l;)e.push(0);e[l]|=h[m]<<8*(3-p%4);n+=1}else if("UTF16BE"===
|
||||
a||"UTF16LE"===a)for(k=0;k<c.length;k+=1){b=c.charCodeAt(k);"UTF16LE"===a&&(m=b&255,b=m<<8|b>>>8);p=n+t;for(l=p>>>2;e.length<=l;)e.push(0);e[l]|=b<<8*(2-p%4);n+=2}return{value:e,binLen:8*n+d}};break;case "B64":d=L;break;case "BYTES":d=K;break;case "ARRAYBUFFER":try{d=new ArrayBuffer(0)}catch(g){throw Error("ARRAYBUFFER not supported by this environment");}d=M;break;default:throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER");}return d}function r(c,a){return c>>>a|c<<32-a}function N(c,
|
||||
a,d){return c&a^~c&d}function O(c,a,d){return c&a^c&d^a&d}function P(c){return r(c,2)^r(c,13)^r(c,22)}function Q(c){return r(c,6)^r(c,11)^r(c,25)}function R(c){return r(c,7)^r(c,18)^c>>>3}function S(c){return r(c,17)^r(c,19)^c>>>10}function T(c,a){var d=(c&65535)+(a&65535);return((c>>>16)+(a>>>16)+(d>>>16)&65535)<<16|d&65535}function U(c,a,d,g){var f=(c&65535)+(a&65535)+(d&65535)+(g&65535);return((c>>>16)+(a>>>16)+(d>>>16)+(g>>>16)+(f>>>16)&65535)<<16|f&65535}function V(c,a,d,g,f){var b=(c&65535)+
|
||||
(a&65535)+(d&65535)+(g&65535)+(f&65535);return((c>>>16)+(a>>>16)+(d>>>16)+(g>>>16)+(f>>>16)+(b>>>16)&65535)<<16|b&65535}function x(c){var a=[],d;if(0===c.lastIndexOf("SHA-",0))switch(a=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],d=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],c){case "SHA-224":break;case "SHA-256":a=d;break;case "SHA-384":a=[new l,new l,new l,new l,new l,new l,new l,new l];break;case "SHA-512":a=
|
||||
[new l,new l,new l,new l,new l,new l,new l,new l];break;default:throw Error("Unknown SHA variant");}else throw Error("No SHA variants supported");return a}function B(c,a,d){var g,f,b,e,h,n,k,m,l,r,p,w,q,x,u,z,A,B,C,D,E,F,v=[],G;if("SHA-224"===d||"SHA-256"===d)r=64,w=1,F=Number,q=T,x=U,u=V,z=R,A=S,B=P,C=Q,E=O,D=N,G=H;else throw Error("Unexpected error in SHA-2 implementation");d=a[0];g=a[1];f=a[2];b=a[3];e=a[4];h=a[5];n=a[6];k=a[7];for(p=0;p<r;p+=1)16>p?(l=p*w,m=c.length<=l?0:c[l],l=c.length<=l+1?
|
||||
0:c[l+1],v[p]=new F(m,l)):v[p]=x(A(v[p-2]),v[p-7],z(v[p-15]),v[p-16]),m=u(k,C(e),D(e,h,n),G[p],v[p]),l=q(B(d),E(d,g,f)),k=n,n=h,h=e,e=q(b,m),b=f,f=g,g=d,d=q(m,l);a[0]=q(d,a[0]);a[1]=q(g,a[1]);a[2]=q(f,a[2]);a[3]=q(b,a[3]);a[4]=q(e,a[4]);a[5]=q(h,a[5]);a[6]=q(n,a[6]);a[7]=q(k,a[7]);return a}var H;H=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,
|
||||
604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];"function"===typeof define&&
|
||||
define.amd?define(function(){return w}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(module.exports=w),exports=w):I.jsSHA=w})(this);
|
||||
Generated
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
A JavaScript implementation of the SHA family of hashes, as
|
||||
defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding
|
||||
HMAC implementation as defined in FIPS PUB 198a
|
||||
|
||||
Copyright Brian Turek 2008-2016
|
||||
Distributed under the BSD License
|
||||
See http://caligatio.github.com/jsSHA/ for more information
|
||||
|
||||
Several functions taken from Paul Johnston
|
||||
*/
|
||||
'use strict';(function(K){function n(d,b,g){var a=0,e=[],h=0,f,r,c,k,l,y,q,A,p=!1,n=[],w=[],t,x=!1,u=!1;g=g||{};f=g.encoding||"UTF8";t=g.numRounds||1;c=C(b,f);if(t!==parseInt(t,10)||1>t)throw Error("numRounds must a integer >= 1");if(0===d.lastIndexOf("SHA3-",0)||0===d.lastIndexOf("SHAKE",0)){var B=6;y=z;A=function(a){var b=[],d;for(d=0;5>d;d+=1)b[d]=a[d].slice();return b};if("SHA3-224"===d)l=1152,k=224;else if("SHA3-256"===d)l=1088,k=256;else if("SHA3-384"===d)l=832,k=384;else if("SHA3-512"===d)l=
|
||||
576,k=512;else if("SHAKE128"===d)l=1344,k=-1,B=31,u=!0;else if("SHAKE256"===d)l=1088,k=-1,B=31,u=!0;else throw Error("Chosen SHA variant is not supported");q=function(a,d,b,e,h){b=l;var g=B,f,r=[],k=b>>>5,c=0,m=d>>>5;for(f=0;f<m&&d>=b;f+=k)e=z(a.slice(f,f+k),e),d-=b;a=a.slice(f);for(d%=b;a.length<k;)a.push(0);f=d>>>3;a[f>>2]^=g<<24-f%4*8;a[k-1]^=128;for(e=z(a,e);32*r.length<h;){a=e[c%5][c/5|0];r.push((a.b&255)<<24|(a.b&65280)<<8|(a.b&16711680)>>8|a.b>>>24);if(32*r.length>=h)break;r.push((a.a&255)<<
|
||||
24|(a.a&65280)<<8|(a.a&16711680)>>8|a.a>>>24);c+=1;0===64*c%b&&z(null,e)}return r}}else throw Error("Chosen SHA variant is not supported");r=v(d);this.setHMACKey=function(b,e,h){var g;if(!0===p)throw Error("HMAC key already set");if(!0===x)throw Error("Cannot set HMAC key after calling update");if(!0===u)throw Error("SHAKE is not supported for HMAC");f=(h||{}).encoding||"UTF8";e=C(e,f)(b);b=e.binLen;e=e.value;g=l>>>3;h=g/4-1;if(g<b/8){for(e=q(e,b,0,v(d),k);e.length<=h;)e.push(0);e[h]&=4294967040}else if(g>
|
||||
b/8){for(;e.length<=h;)e.push(0);e[h]&=4294967040}for(b=0;b<=h;b+=1)n[b]=e[b]^909522486,w[b]=e[b]^1549556828;r=y(n,r);a=l;p=!0};this.update=function(b){var d,f,g,k=0,D=l>>>5;d=c(b,e,h);b=d.binLen;f=d.value;d=b>>>5;for(g=0;g<d;g+=D)k+l<=b&&(r=y(f.slice(g,g+D),r),k+=l);a+=k;e=f.slice(k>>>5);h=b%l;x=!0};this.getHash=function(b,g){var f,c,l,m;if(!0===p)throw Error("Cannot call getHash after setting HMAC key");l=E(g);if(!0===u){if(-1===l.shakeLen)throw Error("shakeLen must be specified in options");k=
|
||||
l.shakeLen}switch(b){case "HEX":f=function(a){return F(a,k,l)};break;case "B64":f=function(a){return G(a,k,l)};break;case "BYTES":f=function(a){return H(a,k)};break;case "ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(L){throw Error("ARRAYBUFFER not supported by this environment");}f=function(a){return I(a,k)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");}m=q(e.slice(),h,a,A(r),k);for(c=1;c<t;c+=1)!0===u&&0!==k%32&&(m[m.length-1]&=4294967040<<24-k%32),m=q(m,k,0,v(d),k);
|
||||
return f(m)};this.getHMAC=function(b,f){var g,c,m,n;if(!1===p)throw Error("Cannot call getHMAC without first setting HMAC key");m=E(f);switch(b){case "HEX":g=function(a){return F(a,k,m)};break;case "B64":g=function(a){return G(a,k,m)};break;case "BYTES":g=function(a){return H(a,k)};break;case "ARRAYBUFFER":try{g=new ArrayBuffer(0)}catch(L){throw Error("ARRAYBUFFER not supported by this environment");}g=function(a){return I(a,k)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER");
|
||||
}c=q(e.slice(),h,a,A(r),k);n=y(w,v(d));n=q(c,k,l,n,k);return g(n)}}function c(d,b){this.a=d;this.b=b}function M(d,b,g){var a=d.length,e,h,f,c,m;b=b||[0];g=g||0;m=g>>>3;if(0!==a%2)throw Error("String of HEX type must be in byte increments");for(e=0;e<a;e+=2){h=parseInt(d.substr(e,2),16);if(isNaN(h))throw Error("String of HEX type contains invalid characters");c=(e>>>1)+m;for(f=c>>>2;b.length<=f;)b.push(0);b[f]|=h<<8*(3-c%4)}return{value:b,binLen:4*a+g}}function N(d,b,g){var a=[],e,h,f,c,a=b||[0];g=
|
||||
g||0;h=g>>>3;for(e=0;e<d.length;e+=1)b=d.charCodeAt(e),c=e+h,f=c>>>2,a.length<=f&&a.push(0),a[f]|=b<<8*(3-c%4);return{value:a,binLen:8*d.length+g}}function O(d,b,g){var a=[],e=0,h,f,c,m,k,l,a=b||[0];g=g||0;b=g>>>3;if(-1===d.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");f=d.indexOf("=");d=d.replace(/\=/g,"");if(-1!==f&&f<d.length)throw Error("Invalid '=' found in base-64 string");for(f=0;f<d.length;f+=4){k=d.substr(f,4);for(c=m=0;c<k.length;c+=1)h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(k[c]),
|
||||
m|=h<<18-6*c;for(c=0;c<k.length-1;c+=1){l=e+b;for(h=l>>>2;a.length<=h;)a.push(0);a[h]|=(m>>>16-8*c&255)<<8*(3-l%4);e+=1}}return{value:a,binLen:8*e+g}}function P(d,b,g){var a=[],e,h,f,a=b||[0];g=g||0;e=g>>>3;for(b=0;b<d.byteLength;b+=1)f=b+e,h=f>>>2,a.length<=h&&a.push(0),a[h]|=d[b]<<8*(3-f%4);return{value:a,binLen:8*d.byteLength+g}}function F(d,b,g){var a="";b/=8;var e,h;for(e=0;e<b;e+=1)h=d[e>>>2]>>>8*(3-e%4),a+="0123456789abcdef".charAt(h>>>4&15)+"0123456789abcdef".charAt(h&15);return g.outputUpper?
|
||||
a.toUpperCase():a}function G(d,b,g){var a="",e=b/8,h,f,c;for(h=0;h<e;h+=3)for(f=h+1<e?d[h+1>>>2]:0,c=h+2<e?d[h+2>>>2]:0,c=(d[h>>>2]>>>8*(3-h%4)&255)<<16|(f>>>8*(3-(h+1)%4)&255)<<8|c>>>8*(3-(h+2)%4)&255,f=0;4>f;f+=1)8*h+6*f<=b?a+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c>>>6*(3-f)&63):a+=g.b64Pad;return a}function H(d,b){var c="",a=b/8,e,h;for(e=0;e<a;e+=1)h=d[e>>>2]>>>8*(3-e%4)&255,c+=String.fromCharCode(h);return c}function I(d,b){var c=b/8,a,e=new ArrayBuffer(c);
|
||||
for(a=0;a<c;a+=1)e[a]=d[a>>>2]>>>8*(3-a%4)&255;return e}function E(d){var b={outputUpper:!1,b64Pad:"=",shakeLen:-1};d=d||{};b.outputUpper=d.outputUpper||!1;!0===d.hasOwnProperty("b64Pad")&&(b.b64Pad=d.b64Pad);if(!0===d.hasOwnProperty("shakeLen")){if(0!==d.shakeLen%8)throw Error("shakeLen must be a multiple of 8");b.shakeLen=d.shakeLen}if("boolean"!==typeof b.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof b.b64Pad)throw Error("Invalid b64Pad formatting option");
|
||||
return b}function C(d,b){var c;switch(b){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(d){case "HEX":c=M;break;case "TEXT":c=function(a,d,c){var f=[],g=[],m=0,k,l,n,q,p,f=d||[0];d=c||0;n=d>>>3;if("UTF8"===b)for(k=0;k<a.length;k+=1)for(c=a.charCodeAt(k),g=[],128>c?g.push(c):2048>c?(g.push(192|c>>>6),g.push(128|c&63)):55296>c||57344<=c?g.push(224|c>>>12,128|c>>>6&63,128|c&63):(k+=1,c=65536+((c&1023)<<10|a.charCodeAt(k)&1023),
|
||||
g.push(240|c>>>18,128|c>>>12&63,128|c>>>6&63,128|c&63)),l=0;l<g.length;l+=1){p=m+n;for(q=p>>>2;f.length<=q;)f.push(0);f[q]|=g[l]<<8*(3-p%4);m+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(k=0;k<a.length;k+=1){c=a.charCodeAt(k);"UTF16LE"===b&&(l=c&255,c=l<<8|c>>>8);p=m+n;for(q=p>>>2;f.length<=q;)f.push(0);f[q]|=c<<8*(2-p%4);m+=2}return{value:f,binLen:8*m+d}};break;case "B64":c=O;break;case "BYTES":c=N;break;case "ARRAYBUFFER":try{c=new ArrayBuffer(0)}catch(a){throw Error("ARRAYBUFFER not supported by this environment");
|
||||
}c=P;break;default:throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER");}return c}function w(d,b){return 32<b?(b=b-32,new c(d.b<<b|d.a>>>32-b,d.a<<b|d.b>>>32-b)):0!==b?new c(d.a<<b|d.b>>>32-b,d.b<<b|d.a>>>32-b):d}function p(d){var b=0,g=0,a;for(a=0;a<arguments.length;a+=1)b^=arguments[a].b,g^=arguments[a].a;return new c(g,b)}function v(d){var b=[];if(0===d.lastIndexOf("SHA3-",0)||0===d.lastIndexOf("SHAKE",0))for(d=0;5>d;d+=1)b[d]=[new c(0,0),new c(0,0),new c(0,0),new c(0,0),new c(0,
|
||||
0)];else throw Error("No SHA variants supported");return b}function z(d,b){var g,a,e,h,f=[],n=[];if(null!==d)for(a=0;a<d.length;a+=2)b[(a>>>1)%5][(a>>>1)/5|0]=p(b[(a>>>1)%5][(a>>>1)/5|0],new c((d[a+1]&255)<<24|(d[a+1]&65280)<<8|(d[a+1]&16711680)>>>8|d[a+1]>>>24,(d[a]&255)<<24|(d[a]&65280)<<8|(d[a]&16711680)>>>8|d[a]>>>24));for(g=0;24>g;g+=1){h=v("SHA3-");for(a=0;5>a;a+=1)f[a]=p(b[a][0],b[a][1],b[a][2],b[a][3],b[a][4]);for(a=0;5>a;a+=1)n[a]=p(f[(a+4)%5],w(f[(a+1)%5],1));for(a=0;5>a;a+=1)for(e=0;5>
|
||||
e;e+=1)b[a][e]=p(b[a][e],n[a]);for(a=0;5>a;a+=1)for(e=0;5>e;e+=1)h[e][(2*a+3*e)%5]=w(b[a][e],x[a][e]);for(a=0;5>a;a+=1)for(e=0;5>e;e+=1)b[a][e]=p(h[a][e],new c(~h[(a+1)%5][e].a&h[(a+2)%5][e].a,~h[(a+1)%5][e].b&h[(a+2)%5][e].b));b[0][0]=p(b[0][0],J[g])}return b}var x,J;J=[new c(0,1),new c(0,32898),new c(2147483648,32906),new c(2147483648,2147516416),new c(0,32907),new c(0,2147483649),new c(2147483648,2147516545),new c(2147483648,32777),new c(0,138),new c(0,136),new c(0,2147516425),new c(0,2147483658),
|
||||
new c(0,2147516555),new c(2147483648,139),new c(2147483648,32905),new c(2147483648,32771),new c(2147483648,32770),new c(2147483648,128),new c(0,32778),new c(2147483648,2147483658),new c(2147483648,2147516545),new c(2147483648,32896),new c(0,2147483649),new c(2147483648,2147516424)];x=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];"function"===typeof define&&define.amd?define(function(){return n}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&
|
||||
(module.exports=n),exports=n):K.jsSHA=n})(this);
|
||||
Generated
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
A JavaScript implementation of the SHA family of hashes, as
|
||||
defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding
|
||||
HMAC implementation as defined in FIPS PUB 198a
|
||||
|
||||
Copyright Brian Turek 2008-2016
|
||||
Distributed under the BSD License
|
||||
See http://caligatio.github.com/jsSHA/ for more information
|
||||
|
||||
Several functions taken from Paul Johnston
|
||||
*/
|
||||
'use strict';(function(L){function y(n,b,d){var c=0,f=[],e=0,a,h,l,k,m,t,u,q,v=!1,r=[],A=[],x,B=!1;d=d||{};a=d.encoding||"UTF8";x=d.numRounds||1;l=C(b,a);if(x!==parseInt(x,10)||1>x)throw Error("numRounds must a integer >= 1");if(0===n.lastIndexOf("SHA-",0))if(t=function(b,c){return D(b,c,n)},u=function(b,c,d,e){var p,f;if("SHA-384"===n||"SHA-512"===n)p=(c+129>>>10<<5)+31,f=32;else throw Error("Unexpected error in SHA-2 implementation");for(;b.length<=p;)b.push(0);b[c>>>5]|=128<<24-c%32;c=c+d;b[p]=
|
||||
c&4294967295;b[p-1]=c/4294967296|0;d=b.length;for(c=0;c<d;c+=f)e=D(b.slice(c,c+f),e,n);if("SHA-384"===n)b=[e[0].a,e[0].b,e[1].a,e[1].b,e[2].a,e[2].b,e[3].a,e[3].b,e[4].a,e[4].b,e[5].a,e[5].b];else if("SHA-512"===n)b=[e[0].a,e[0].b,e[1].a,e[1].b,e[2].a,e[2].b,e[3].a,e[3].b,e[4].a,e[4].b,e[5].a,e[5].b,e[6].a,e[6].b,e[7].a,e[7].b];else throw Error("Unexpected error in SHA-2 implementation");return b},q=function(b){return b.slice()},"SHA-384"===n)m=1024,k=384;else if("SHA-512"===n)m=1024,k=512;else throw Error("Chosen SHA variant is not supported");
|
||||
else throw Error("Chosen SHA variant is not supported");h=z(n);this.setHMACKey=function(b,d,e){var f;if(!0===v)throw Error("HMAC key already set");if(!0===B)throw Error("Cannot set HMAC key after calling update");a=(e||{}).encoding||"UTF8";d=C(d,a)(b);b=d.binLen;d=d.value;f=m>>>3;e=f/4-1;if(f<b/8){for(d=u(d,b,0,z(n),k);d.length<=e;)d.push(0);d[e]&=4294967040}else if(f>b/8){for(;d.length<=e;)d.push(0);d[e]&=4294967040}for(b=0;b<=e;b+=1)r[b]=d[b]^909522486,A[b]=d[b]^1549556828;h=t(r,h);c=m;v=!0};this.update=
|
||||
function(b){var d,n,a,g=0,k=m>>>5;d=l(b,f,e);b=d.binLen;n=d.value;d=b>>>5;for(a=0;a<d;a+=k)g+m<=b&&(h=t(n.slice(a,a+k),h),g+=m);c+=g;f=n.slice(g>>>5);e=b%m;B=!0};this.getHash=function(b,d){var a,g,m,l;if(!0===v)throw Error("Cannot call getHash after setting HMAC key");m=E(d);switch(b){case "HEX":a=function(b){return F(b,k,m)};break;case "B64":a=function(b){return G(b,k,m)};break;case "BYTES":a=function(b){return H(b,k)};break;case "ARRAYBUFFER":try{g=new ArrayBuffer(0)}catch(w){throw Error("ARRAYBUFFER not supported by this environment");
|
||||
}a=function(b){return I(b,k)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");}l=u(f.slice(),e,c,q(h),k);for(g=1;g<x;g+=1)l=u(l,k,0,z(n),k);return a(l)};this.getHMAC=function(b,d){var a,g,l,r;if(!1===v)throw Error("Cannot call getHMAC without first setting HMAC key");l=E(d);switch(b){case "HEX":a=function(b){return F(b,k,l)};break;case "B64":a=function(b){return G(b,k,l)};break;case "BYTES":a=function(b){return H(b,k)};break;case "ARRAYBUFFER":try{a=new ArrayBuffer(0)}catch(w){throw Error("ARRAYBUFFER not supported by this environment");
|
||||
}a=function(b){return I(b,k)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER");}g=u(f.slice(),e,c,q(h),k);r=t(A,z(n));r=u(g,k,m,r,k);return a(r)}}function c(c,b){this.a=c;this.b=b}function M(c,b,d){var a=c.length,f,e,g,h,l;b=b||[0];d=d||0;l=d>>>3;if(0!==a%2)throw Error("String of HEX type must be in byte increments");for(f=0;f<a;f+=2){e=parseInt(c.substr(f,2),16);if(isNaN(e))throw Error("String of HEX type contains invalid characters");h=(f>>>1)+l;for(g=h>>>2;b.length<=
|
||||
g;)b.push(0);b[g]|=e<<8*(3-h%4)}return{value:b,binLen:4*a+d}}function N(c,b,d){var a=[],f,e,g,h,a=b||[0];d=d||0;e=d>>>3;for(f=0;f<c.length;f+=1)b=c.charCodeAt(f),h=f+e,g=h>>>2,a.length<=g&&a.push(0),a[g]|=b<<8*(3-h%4);return{value:a,binLen:8*c.length+d}}function O(c,b,d){var a=[],f=0,e,g,h,l,k,m,a=b||[0];d=d||0;b=d>>>3;if(-1===c.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");g=c.indexOf("=");c=c.replace(/\=/g,"");if(-1!==g&&g<c.length)throw Error("Invalid '=' found in base-64 string");
|
||||
for(g=0;g<c.length;g+=4){k=c.substr(g,4);for(h=l=0;h<k.length;h+=1)e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(k[h]),l|=e<<18-6*h;for(h=0;h<k.length-1;h+=1){m=f+b;for(e=m>>>2;a.length<=e;)a.push(0);a[e]|=(l>>>16-8*h&255)<<8*(3-m%4);f+=1}}return{value:a,binLen:8*f+d}}function P(c,b,d){var a=[],f,e,g,a=b||[0];d=d||0;f=d>>>3;for(b=0;b<c.byteLength;b+=1)g=b+f,e=g>>>2,a.length<=e&&a.push(0),a[e]|=c[b]<<8*(3-g%4);return{value:a,binLen:8*c.byteLength+d}}function F(c,b,d){var a=
|
||||
"";b/=8;var f,e;for(f=0;f<b;f+=1)e=c[f>>>2]>>>8*(3-f%4),a+="0123456789abcdef".charAt(e>>>4&15)+"0123456789abcdef".charAt(e&15);return d.outputUpper?a.toUpperCase():a}function G(c,b,d){var a="",f=b/8,e,g,h;for(e=0;e<f;e+=3)for(g=e+1<f?c[e+1>>>2]:0,h=e+2<f?c[e+2>>>2]:0,h=(c[e>>>2]>>>8*(3-e%4)&255)<<16|(g>>>8*(3-(e+1)%4)&255)<<8|h>>>8*(3-(e+2)%4)&255,g=0;4>g;g+=1)8*e+6*g<=b?a+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(h>>>6*(3-g)&63):a+=d.b64Pad;return a}function H(c,
|
||||
b){var d="",a=b/8,f,e;for(f=0;f<a;f+=1)e=c[f>>>2]>>>8*(3-f%4)&255,d+=String.fromCharCode(e);return d}function I(c,b){var d=b/8,a,f=new ArrayBuffer(d);for(a=0;a<d;a+=1)f[a]=c[a>>>2]>>>8*(3-a%4)&255;return f}function E(c){var b={outputUpper:!1,b64Pad:"=",shakeLen:-1};c=c||{};b.outputUpper=c.outputUpper||!1;!0===c.hasOwnProperty("b64Pad")&&(b.b64Pad=c.b64Pad);if("boolean"!==typeof b.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!==typeof b.b64Pad)throw Error("Invalid b64Pad formatting option");
|
||||
return b}function C(c,b){var d;switch(b){case "UTF8":case "UTF16BE":case "UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE");}switch(c){case "HEX":d=M;break;case "TEXT":d=function(c,d,a){var n=[],h=[],l=0,k,m,t,u,q,n=d||[0];d=a||0;t=d>>>3;if("UTF8"===b)for(k=0;k<c.length;k+=1)for(a=c.charCodeAt(k),h=[],128>a?h.push(a):2048>a?(h.push(192|a>>>6),h.push(128|a&63)):55296>a||57344<=a?h.push(224|a>>>12,128|a>>>6&63,128|a&63):(k+=1,a=65536+((a&1023)<<10|c.charCodeAt(k)&1023),
|
||||
h.push(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|a&63)),m=0;m<h.length;m+=1){q=l+t;for(u=q>>>2;n.length<=u;)n.push(0);n[u]|=h[m]<<8*(3-q%4);l+=1}else if("UTF16BE"===b||"UTF16LE"===b)for(k=0;k<c.length;k+=1){a=c.charCodeAt(k);"UTF16LE"===b&&(m=a&255,a=m<<8|a>>>8);q=l+t;for(u=q>>>2;n.length<=u;)n.push(0);n[u]|=a<<8*(2-q%4);l+=2}return{value:n,binLen:8*l+d}};break;case "B64":d=O;break;case "BYTES":d=N;break;case "ARRAYBUFFER":try{d=new ArrayBuffer(0)}catch(a){throw Error("ARRAYBUFFER not supported by this environment");
|
||||
}d=P;break;default:throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER");}return d}function v(a,b){var d=null,d=new c(a.a,a.b);return d=32>=b?new c(d.a>>>b|d.b<<32-b&4294967295,d.b>>>b|d.a<<32-b&4294967295):new c(d.b>>>b-32|d.a<<64-b&4294967295,d.a>>>b-32|d.b<<64-b&4294967295)}function J(a,b){var d=null;return d=32>=b?new c(a.a>>>b,a.b>>>b|a.a<<32-b&4294967295):new c(0,a.a>>>b-32)}function Q(a,b,d){return new c(a.a&b.a^~a.a&d.a,a.b&b.b^~a.b&d.b)}function R(a,b,d){return new c(a.a&b.a^
|
||||
a.a&d.a^b.a&d.a,a.b&b.b^a.b&d.b^b.b&d.b)}function S(a){var b=v(a,28),d=v(a,34);a=v(a,39);return new c(b.a^d.a^a.a,b.b^d.b^a.b)}function T(a){var b=v(a,14),d=v(a,18);a=v(a,41);return new c(b.a^d.a^a.a,b.b^d.b^a.b)}function U(a){var b=v(a,1),d=v(a,8);a=J(a,7);return new c(b.a^d.a^a.a,b.b^d.b^a.b)}function V(a){var b=v(a,19),d=v(a,61);a=J(a,6);return new c(b.a^d.a^a.a,b.b^d.b^a.b)}function W(a,b){var d,p,f;d=(a.b&65535)+(b.b&65535);p=(a.b>>>16)+(b.b>>>16)+(d>>>16);f=(p&65535)<<16|d&65535;d=(a.a&65535)+
|
||||
(b.a&65535)+(p>>>16);p=(a.a>>>16)+(b.a>>>16)+(d>>>16);return new c((p&65535)<<16|d&65535,f)}function X(a,b,d,p){var f,e,g;f=(a.b&65535)+(b.b&65535)+(d.b&65535)+(p.b&65535);e=(a.b>>>16)+(b.b>>>16)+(d.b>>>16)+(p.b>>>16)+(f>>>16);g=(e&65535)<<16|f&65535;f=(a.a&65535)+(b.a&65535)+(d.a&65535)+(p.a&65535)+(e>>>16);e=(a.a>>>16)+(b.a>>>16)+(d.a>>>16)+(p.a>>>16)+(f>>>16);return new c((e&65535)<<16|f&65535,g)}function Y(a,b,d,p,f){var e,g,h;e=(a.b&65535)+(b.b&65535)+(d.b&65535)+(p.b&65535)+(f.b&65535);g=(a.b>>>
|
||||
16)+(b.b>>>16)+(d.b>>>16)+(p.b>>>16)+(f.b>>>16)+(e>>>16);h=(g&65535)<<16|e&65535;e=(a.a&65535)+(b.a&65535)+(d.a&65535)+(p.a&65535)+(f.a&65535)+(g>>>16);g=(a.a>>>16)+(b.a>>>16)+(d.a>>>16)+(p.a>>>16)+(f.a>>>16)+(e>>>16);return new c((g&65535)<<16|e&65535,h)}function z(a){var b=[],d;if(0===a.lastIndexOf("SHA-",0))switch(b=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],d=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],a){case "SHA-224":break;
|
||||
case "SHA-256":b=d;break;case "SHA-384":b=[new c(3418070365,b[0]),new c(1654270250,b[1]),new c(2438529370,b[2]),new c(355462360,b[3]),new c(1731405415,b[4]),new c(41048885895,b[5]),new c(3675008525,b[6]),new c(1203062813,b[7])];break;case "SHA-512":b=[new c(d[0],4089235720),new c(d[1],2227873595),new c(d[2],4271175723),new c(d[3],1595750129),new c(d[4],2917565137),new c(d[5],725511199),new c(d[6],4215389547),new c(d[7],327033209)];break;default:throw Error("Unknown SHA variant");}else throw Error("No SHA variants supported");
|
||||
return b}function D(a,b,d){var p,f,e,g,h,l,k,m,t,u,q,v,r,A,x,B,y,z,C,D,E,F,w=[],G;if("SHA-384"===d||"SHA-512"===d)u=80,v=2,F=c,r=W,A=X,x=Y,B=U,y=V,z=S,C=T,E=R,D=Q,G=K;else throw Error("Unexpected error in SHA-2 implementation");d=b[0];p=b[1];f=b[2];e=b[3];g=b[4];h=b[5];l=b[6];k=b[7];for(q=0;q<u;q+=1)16>q?(t=q*v,m=a.length<=t?0:a[t],t=a.length<=t+1?0:a[t+1],w[q]=new F(m,t)):w[q]=A(y(w[q-2]),w[q-7],B(w[q-15]),w[q-16]),m=x(k,C(g),D(g,h,l),G[q],w[q]),t=r(z(d),E(d,p,f)),k=l,l=h,h=g,g=r(e,m),e=f,f=p,p=
|
||||
d,d=r(m,t);b[0]=r(d,b[0]);b[1]=r(p,b[1]);b[2]=r(f,b[2]);b[3]=r(e,b[3]);b[4]=r(g,b[4]);b[5]=r(h,b[5]);b[6]=r(l,b[6]);b[7]=r(k,b[7]);return b}var a,K;a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,
|
||||
773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];K=[new c(a[0],3609767458),new c(a[1],602891725),new c(a[2],3964484399),new c(a[3],2173295548),new c(a[4],4081628472),new c(a[5],3053834265),new c(a[6],2937671579),new c(a[7],
|
||||
3664609560),new c(a[8],2734883394),new c(a[9],1164996542),new c(a[10],1323610764),new c(a[11],3590304994),new c(a[12],4068182383),new c(a[13],991336113),new c(a[14],633803317),new c(a[15],3479774868),new c(a[16],2666613458),new c(a[17],944711139),new c(a[18],2341262773),new c(a[19],2007800933),new c(a[20],1495990901),new c(a[21],1856431235),new c(a[22],3175218132),new c(a[23],2198950837),new c(a[24],3999719339),new c(a[25],766784016),new c(a[26],2566594879),new c(a[27],3203337956),new c(a[28],1034457026),
|
||||
new c(a[29],2466948901),new c(a[30],3758326383),new c(a[31],168717936),new c(a[32],1188179964),new c(a[33],1546045734),new c(a[34],1522805485),new c(a[35],2643833823),new c(a[36],2343527390),new c(a[37],1014477480),new c(a[38],1206759142),new c(a[39],344077627),new c(a[40],1290863460),new c(a[41],3158454273),new c(a[42],3505952657),new c(a[43],106217008),new c(a[44],3606008344),new c(a[45],1432725776),new c(a[46],1467031594),new c(a[47],851169720),new c(a[48],3100823752),new c(a[49],1363258195),new c(a[50],
|
||||
3750685593),new c(a[51],3785050280),new c(a[52],3318307427),new c(a[53],3812723403),new c(a[54],2003034995),new c(a[55],3602036899),new c(a[56],1575990012),new c(a[57],1125592928),new c(a[58],2716904306),new c(a[59],442776044),new c(a[60],593698344),new c(a[61],3733110249),new c(a[62],2999351573),new c(a[63],3815920427),new c(3391569614,3928383900),new c(3515267271,566280711),new c(3940187606,3454069534),new c(4118630271,4000239992),new c(116418474,1914138554),new c(174292421,2731055270),new c(289380356,
|
||||
3203993006),new c(460393269,320620315),new c(685471733,587496836),new c(852142971,1086792851),new c(1017036298,365543100),new c(1126000580,2618297676),new c(1288033470,3409855158),new c(1501505948,4234509866),new c(1607167915,987167468),new c(1816402316,1246189591)];"function"===typeof define&&define.amd?define(function(){return y}):"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(module.exports=y),exports=y):L.jsSHA=y})(this);
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
module.exports = function (grunt) {
|
||||
|
||||
grunt.initConfig({
|
||||
uglify: {
|
||||
options: {
|
||||
report: 'gzip'
|
||||
},
|
||||
promiz: {
|
||||
files: {
|
||||
'promiz.min.js': ['promiz.js']
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
|
||||
grunt.registerTask('default', ['uglify']);
|
||||
|
||||
};
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Zolmeister
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
Generated
Vendored
+88
@@ -0,0 +1,88 @@
|
||||

|
||||
======
|
||||
<a href="http://promises-aplus.github.com/promises-spec">
|
||||
<img src="https://raw.github.com/Zolmeister/promiz/master/imgs/promise-logo-small.png"
|
||||
align="right" alt="Promises/A+ logo" />
|
||||
</a>
|
||||
A polyfill for ES6-style Promises in 913 bytes (gzip) (v0.3 [Blog Post](http://www.zolmeister.com/2014/01/promiz-micro-promises-in-228-bytes.html)) ~~([How it was built](http://www.zolmeister.com/2013/07/promizjs.html))~~
|
||||

|
||||
## Install
|
||||
```bash
|
||||
# Node.js
|
||||
npm install promiz --save
|
||||
|
||||
# Bower
|
||||
bower install promiz --save
|
||||
```
|
||||
```html
|
||||
<!-- Browser -->
|
||||
<script src='promiz.js'></script>
|
||||
```
|
||||
Promiz - **913 bytes** (min + gzip) - as reported by uglify.js
|
||||
## Promiz
|
||||
[HTML5rocks tutorial](http://www.html5rocks.com/en/tutorials/es6/promises/)
|
||||
### Constructor - `new Promise(Function<resolve, reject>)`
|
||||
```js
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
if ('itIsRaining' && Math.random() * 10 === 2) {
|
||||
reject(new Error('reason'))
|
||||
} else {
|
||||
resolve(42)
|
||||
}
|
||||
})
|
||||
```
|
||||
### `Promise.reject({reason})`
|
||||
```js
|
||||
promise = Promise.reject(new Error('reason'))
|
||||
```
|
||||
### `Promise.resolve({value})`
|
||||
```js
|
||||
promise = Promise.resolve(42)
|
||||
```
|
||||
### `promise.then({Function}, {Function})`
|
||||
```js
|
||||
promise = Promise.resolve(42)
|
||||
promise.then(function (success) {
|
||||
return 'Promise resolved to: ' + success
|
||||
}, function (failure) {
|
||||
return 'Promise failed with: ' + failure
|
||||
})
|
||||
```
|
||||
### `promise.catch({Function})`
|
||||
```js
|
||||
promise = Promise.reject(new Error('failure'))
|
||||
promise.catch(function (failure) {
|
||||
return 'Promise failed with: ' + failure
|
||||
})
|
||||
```
|
||||
### `Promise.all({iterable})`
|
||||
```js
|
||||
promise1 = Promise.resolve(1)
|
||||
promise2 = Promise.resolve(2)
|
||||
Promise.all([promise1, 123, promise2])
|
||||
.then(function (promises) {
|
||||
promises[0] === 1
|
||||
promises[1] === 123
|
||||
promises[2] === 2
|
||||
})
|
||||
```
|
||||
### `Promise.race({iterable})`
|
||||
```js
|
||||
promise1 = new Promise()
|
||||
promise2 = new Promise()
|
||||
|
||||
setTimeout(function () {
|
||||
promise1.resolve('z')
|
||||
}, 10)
|
||||
|
||||
setTimeout(function () {
|
||||
promise2.resolve('l')
|
||||
}, 100)
|
||||
|
||||
Promise.race([promise1, promise2])
|
||||
.then(function (winner) {
|
||||
winner === 'z'
|
||||
})
|
||||
```
|
||||
|
||||
### Licence: MIT
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "promiz",
|
||||
"main": "promiz.js",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://github.com/Zolmeister/promiz",
|
||||
"authors": [
|
||||
"Zolmeister <zolikahan@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"test",
|
||||
"imgs",
|
||||
".*"
|
||||
]
|
||||
}
|
||||
Generated
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
Generated
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 164 KiB |
Generated
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
Generated
Vendored
BIN
Binary file not shown.
Generated
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
Generated
Vendored
+77
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"promiz@1.0.5",
|
||||
"C:\\Users\\tiago.kayaya\\development\\gabinete-digital"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "promiz@1.0.5",
|
||||
"_id": "promiz@1.0.5",
|
||||
"_inBundle": true,
|
||||
"_integrity": "sha1-8m/bKYdWWJeC9lCaax61SnA40zU=",
|
||||
"_location": "/cordova-plugin-mfp/promiz",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "promiz@1.0.5",
|
||||
"name": "promiz",
|
||||
"escapedName": "promiz",
|
||||
"rawSpec": "1.0.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cordova-plugin-mfp"
|
||||
],
|
||||
"_resolved": false,
|
||||
"_shasum": "f26fdb298756589782f6509a6b1eb54a7038d335",
|
||||
"_spec": "1.0.5",
|
||||
"_where": "C:\\Users\\tiago.kayaya\\development\\gabinete-digital",
|
||||
"author": {
|
||||
"name": "Zolmeister"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Zolmeister/promiz/issues"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "A proper compact promise (promises/A+ spec compliant) library.",
|
||||
"devDependencies": {
|
||||
"clay-chai": "0.0.2",
|
||||
"grunt": "~0.4.2",
|
||||
"grunt-contrib-uglify": "^0.9.1",
|
||||
"mocha": "2.0.1",
|
||||
"promises-aplus-tests": "^2.1.1",
|
||||
"promises-es6-tests": "0.5.0"
|
||||
},
|
||||
"gitHead": "381d65d8abe30f2077f3f9d7ccdcb41e58a8fb5a",
|
||||
"homepage": "https://github.com/Zolmeister/promiz#readme",
|
||||
"keywords": [
|
||||
"promiz",
|
||||
"promise",
|
||||
"promise/A+",
|
||||
"library",
|
||||
"promises",
|
||||
"promises-a",
|
||||
"promises-aplus",
|
||||
"deffered",
|
||||
"future",
|
||||
"async",
|
||||
"flow control"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "promiz.js",
|
||||
"name": "promiz",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Zolmeister/promiz.git"
|
||||
},
|
||||
"scripts": {
|
||||
"all": "mocha test/promiz.js && promises-aplus-tests test/spec-adapter && promises-es6-tests test/spec-adapter",
|
||||
"es6": "promises-es6-tests test/spec-adapter",
|
||||
"spec": "promises-aplus-tests test/spec-adapter",
|
||||
"test": "mocha test/promiz.js"
|
||||
},
|
||||
"version": "1.0.5"
|
||||
}
|
||||
Generated
Vendored
+318
@@ -0,0 +1,318 @@
|
||||
(function () {
|
||||
global = this
|
||||
|
||||
var queueId = 1
|
||||
var queue = {}
|
||||
var isRunningTask = false
|
||||
|
||||
if (!global.setImmediate)
|
||||
global.addEventListener('message', function (e) {
|
||||
if (e.source == global){
|
||||
if (isRunningTask)
|
||||
nextTick(queue[e.data])
|
||||
else {
|
||||
isRunningTask = true
|
||||
try {
|
||||
queue[e.data]()
|
||||
} catch (e) {}
|
||||
|
||||
delete queue[e.data]
|
||||
isRunningTask = false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function nextTick(fn) {
|
||||
if (global.setImmediate) setImmediate(fn)
|
||||
// if inside of web worker
|
||||
else if (global.importScripts) setTimeout(fn)
|
||||
else {
|
||||
queueId++
|
||||
queue[queueId] = fn
|
||||
global.postMessage(queueId, '*')
|
||||
}
|
||||
}
|
||||
|
||||
Deferred.resolve = function (value) {
|
||||
if (!(this._d == 1))
|
||||
throw TypeError()
|
||||
|
||||
if (value instanceof Deferred)
|
||||
return value
|
||||
|
||||
return new Deferred(function (resolve) {
|
||||
resolve(value)
|
||||
})
|
||||
}
|
||||
|
||||
Deferred.reject = function (value) {
|
||||
if (!(this._d == 1))
|
||||
throw TypeError()
|
||||
|
||||
return new Deferred(function (resolve, reject) {
|
||||
reject(value)
|
||||
})
|
||||
}
|
||||
|
||||
Deferred.all = function (arr) {
|
||||
if (!(this._d == 1))
|
||||
throw TypeError()
|
||||
|
||||
if (!(arr instanceof Array))
|
||||
return Deferred.reject(TypeError())
|
||||
|
||||
var d = new Deferred()
|
||||
|
||||
function done(e, v) {
|
||||
if (v)
|
||||
return d.resolve(v)
|
||||
|
||||
if (e)
|
||||
return d.reject(e)
|
||||
|
||||
var unresolved = arr.reduce(function (cnt, v) {
|
||||
if (v && v.then)
|
||||
return cnt + 1
|
||||
return cnt
|
||||
}, 0)
|
||||
|
||||
if(unresolved == 0)
|
||||
d.resolve(arr)
|
||||
|
||||
arr.map(function (v, i) {
|
||||
if (v && v.then)
|
||||
v.then(function (r) {
|
||||
arr[i] = r
|
||||
done()
|
||||
return r
|
||||
}, done)
|
||||
})
|
||||
}
|
||||
|
||||
done()
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
Deferred.race = function (arr) {
|
||||
if (!(this._d == 1))
|
||||
throw TypeError()
|
||||
|
||||
if (!(arr instanceof Array))
|
||||
return Deferred.reject(TypeError())
|
||||
|
||||
if (arr.length == 0)
|
||||
return new Deferred()
|
||||
|
||||
var d = new Deferred()
|
||||
|
||||
function done(e, v) {
|
||||
if (v)
|
||||
return d.resolve(v)
|
||||
|
||||
if (e)
|
||||
return d.reject(e)
|
||||
|
||||
var unresolved = arr.reduce(function (cnt, v) {
|
||||
if (v && v.then)
|
||||
return cnt + 1
|
||||
return cnt
|
||||
}, 0)
|
||||
|
||||
if(unresolved == 0)
|
||||
d.resolve(arr)
|
||||
|
||||
arr.map(function (v, i) {
|
||||
if (v && v.then)
|
||||
v.then(function (r) {
|
||||
done(null, r)
|
||||
}, done)
|
||||
})
|
||||
}
|
||||
|
||||
done()
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
Deferred._d = 1
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Deferred(resolver) {
|
||||
'use strict'
|
||||
if (typeof resolver != 'function' && resolver != undefined)
|
||||
throw TypeError()
|
||||
|
||||
if (typeof this != 'object' || (this && this.then))
|
||||
throw TypeError()
|
||||
|
||||
// states
|
||||
// 0: pending
|
||||
// 1: resolving
|
||||
// 2: rejecting
|
||||
// 3: resolved
|
||||
// 4: rejected
|
||||
var self = this,
|
||||
state = 0,
|
||||
val = 0,
|
||||
next = [],
|
||||
fn, er;
|
||||
|
||||
self['promise'] = self
|
||||
|
||||
self['resolve'] = function (v) {
|
||||
fn = self.fn
|
||||
er = self.er
|
||||
if (!state) {
|
||||
val = v
|
||||
state = 1
|
||||
|
||||
nextTick(fire)
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
self['reject'] = function (v) {
|
||||
fn = self.fn
|
||||
er = self.er
|
||||
if (!state) {
|
||||
val = v
|
||||
state = 2
|
||||
|
||||
nextTick(fire)
|
||||
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
self['_d'] = 1
|
||||
|
||||
self['then'] = function (_fn, _er) {
|
||||
if (!(this._d == 1))
|
||||
throw TypeError()
|
||||
|
||||
var d = new Deferred()
|
||||
|
||||
d.fn = _fn
|
||||
d.er = _er
|
||||
if (state == 3) {
|
||||
d.resolve(val)
|
||||
}
|
||||
else if (state == 4) {
|
||||
d.reject(val)
|
||||
}
|
||||
else {
|
||||
next.push(d)
|
||||
}
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
self['catch'] = function (_er) {
|
||||
return self['then'](null, _er)
|
||||
}
|
||||
|
||||
var finish = function (type) {
|
||||
state = type || 4
|
||||
next.map(function (p) {
|
||||
state == 3 && p.resolve(val) || p.reject(val)
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof resolver == 'function')
|
||||
resolver(self['resolve'], self['reject'])
|
||||
} catch (e) {
|
||||
self['reject'](e)
|
||||
}
|
||||
|
||||
return self
|
||||
|
||||
// ref : reference to 'then' function
|
||||
// cb, ec, cn : successCallback, failureCallback, notThennableCallback
|
||||
function thennable (ref, cb, ec, cn) {
|
||||
// Promises can be rejected with other promises, which should pass through
|
||||
if (state == 2) {
|
||||
return cn()
|
||||
}
|
||||
if ((typeof val == 'object' || typeof val == 'function') && typeof ref == 'function') {
|
||||
try {
|
||||
|
||||
// cnt protects against abuse calls from spec checker
|
||||
var cnt = 0
|
||||
ref.call(val, function (v) {
|
||||
if (cnt++) return
|
||||
val = v
|
||||
cb()
|
||||
}, function (v) {
|
||||
if (cnt++) return
|
||||
val = v
|
||||
ec()
|
||||
})
|
||||
} catch (e) {
|
||||
val = e
|
||||
ec()
|
||||
}
|
||||
} else {
|
||||
cn()
|
||||
}
|
||||
};
|
||||
|
||||
function fire() {
|
||||
|
||||
// check if it's a thenable
|
||||
var ref;
|
||||
try {
|
||||
ref = val && val.then
|
||||
} catch (e) {
|
||||
val = e
|
||||
state = 2
|
||||
return fire()
|
||||
}
|
||||
|
||||
thennable(ref, function () {
|
||||
state = 1
|
||||
fire()
|
||||
}, function () {
|
||||
state = 2
|
||||
fire()
|
||||
}, function () {
|
||||
try {
|
||||
if (state == 1 && typeof fn == 'function') {
|
||||
val = fn(val)
|
||||
}
|
||||
|
||||
else if (state == 2 && typeof er == 'function') {
|
||||
val = er(val)
|
||||
state = 1
|
||||
}
|
||||
} catch (e) {
|
||||
val = e
|
||||
return finish()
|
||||
}
|
||||
|
||||
if (val == self) {
|
||||
val = TypeError()
|
||||
finish()
|
||||
} else thennable(ref, function () {
|
||||
finish(3)
|
||||
}, finish, function () {
|
||||
finish(state == 1 && 3)
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Export our library object, either for node.js or as a globally scoped variable
|
||||
if (typeof module != 'undefined') {
|
||||
module['exports'] = Deferred
|
||||
} else {
|
||||
global['Promise'] = global['Promise'] || Deferred
|
||||
}
|
||||
})()
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
!function(){function a(a){global.setImmediate?setImmediate(a):global.importScripts?setTimeout(a):(c++,d[c]=a,global.postMessage(c,"*"))}function b(c){"use strict";function d(a,b,c,d){if(2==i)return d();if("object"!=typeof j&&"function"!=typeof j||"function"!=typeof a)d();else try{var e=0;a.call(j,function(a){e++||(j=a,b())},function(a){e++||(j=a,c())})}catch(f){j=f,c()}}function e(){var a;try{a=j&&j.then}catch(b){return j=b,i=2,e()}d(a,function(){i=1,e()},function(){i=2,e()},function(){try{1==i&&"function"==typeof f?j=f(j):2==i&&"function"==typeof g&&(j=g(j),i=1)}catch(b){return j=b,l()}j==h?(j=TypeError(),l()):d(a,function(){l(3)},l,function(){l(1==i&&3)})})}if("function"!=typeof c&&void 0!=c)throw TypeError();if("object"!=typeof this||this&&this.then)throw TypeError();var f,g,h=this,i=0,j=0,k=[];h.promise=h,h.resolve=function(b){return f=h.fn,g=h.er,i||(j=b,i=1,a(e)),h},h.reject=function(b){return f=h.fn,g=h.er,i||(j=b,i=2,a(e)),h},h._d=1,h.then=function(a,c){if(1!=this._d)throw TypeError();var d=new b;return d.fn=a,d.er=c,3==i?d.resolve(j):4==i?d.reject(j):k.push(d),d},h["catch"]=function(a){return h.then(null,a)};var l=function(a){i=a||4,k.map(function(a){3==i&&a.resolve(j)||a.reject(j)})};try{"function"==typeof c&&c(h.resolve,h.reject)}catch(m){h.reject(m)}return h}global=this;var c=1,d={},e=!1;global.setImmediate||global.addEventListener("message",function(b){if(b.source==global)if(e)a(d[b.data]);else{e=!0;try{d[b.data]()}catch(b){}delete d[b.data],e=!1}}),b.resolve=function(a){if(1!=this._d)throw TypeError();return a instanceof b?a:new b(function(b){b(a)})},b.reject=function(a){if(1!=this._d)throw TypeError();return new b(function(b,c){c(a)})},b.all=function(a){function c(b,e){if(e)return d.resolve(e);if(b)return d.reject(b);var f=a.reduce(function(a,b){return b&&b.then?a+1:a},0);0==f&&d.resolve(a),a.map(function(b,d){b&&b.then&&b.then(function(b){return a[d]=b,c(),b},c)})}if(1!=this._d)throw TypeError();if(!(a instanceof Array))return b.reject(TypeError());var d=new b;return c(),d},b.race=function(a){function c(b,e){if(e)return d.resolve(e);if(b)return d.reject(b);var f=a.reduce(function(a,b){return b&&b.then?a+1:a},0);0==f&&d.resolve(a),a.map(function(a,b){a&&a.then&&a.then(function(a){c(null,a)},c)})}if(1!=this._d)throw TypeError();if(!(a instanceof Array))return b.reject(TypeError());if(0==a.length)return new b;var d=new b;return c(),d},b._d=1,"undefined"!=typeof module?module.exports=b:global.Promise=global.Promise||b}();
|
||||
Generated
Vendored
+332
@@ -0,0 +1,332 @@
|
||||
var Promise = require('./../promiz')
|
||||
var should = require('clay-chai').should()
|
||||
var expect = require('clay-chai').expect
|
||||
|
||||
describe('promiz library', function(){
|
||||
this.timeout(200)
|
||||
|
||||
describe('constructor', function () {
|
||||
it('resolves', function (done) {
|
||||
Promise.resolve(22).then(function (tt) {
|
||||
tt.should.be(22)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects', function (done) {
|
||||
Promise.reject(new Error('abc')).then(function () {
|
||||
done(new Error('then recieved an error'))
|
||||
}, function (err) {
|
||||
err.message.should.be('abc')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects with resolved promise', function (done) {
|
||||
Promise.reject(Promise.resolve()).then(function () {
|
||||
done(new Error('then recieved an error'))
|
||||
}, function (err) {
|
||||
expect(err instanceof Promise).to.be(true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('basic user deferreds', function(){
|
||||
|
||||
function testPromise() {
|
||||
return new Promise(function (resolve, reject) {
|
||||
process.nextTick(function(){
|
||||
resolve(22)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
it('allows custom promise functions through deferred object', function(done) {
|
||||
var promise = testPromise()
|
||||
|
||||
|
||||
var called = 0
|
||||
promise.then(function(twentyTwo){
|
||||
expect(twentyTwo).to.be(22)
|
||||
expect(called).to.be(0)
|
||||
called++
|
||||
return 99
|
||||
})
|
||||
|
||||
promise.then(function(twentyTwo){
|
||||
expect(twentyTwo).to.be(22)
|
||||
expect(called).to.be(1)
|
||||
called++
|
||||
return 99
|
||||
})
|
||||
|
||||
promise.then(function(twentyTwo){
|
||||
expect(twentyTwo).to.be(22)
|
||||
expect(called).to.be(2)
|
||||
return 99
|
||||
})
|
||||
|
||||
promise.then(testPromise).then(function(twentyTwo){
|
||||
expect(twentyTwo).to.be(22)
|
||||
}).then(function(){
|
||||
return testPromise()
|
||||
}).then(function(twentyTwo){
|
||||
expect(twentyTwo).to.be(22)
|
||||
done()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
it('allows resolving with a thenable', function(done) {
|
||||
|
||||
|
||||
var d = new Promise()
|
||||
d.resolve(testPromise())
|
||||
d.then(function(twentyTwo){
|
||||
expect(twentyTwo).to.be(22)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('follows multi-use spec', function(done){
|
||||
|
||||
|
||||
var promise = testPromise()
|
||||
|
||||
var called = 0
|
||||
promise.then(function(twentyTwo) {
|
||||
expect(called++).to.be(0)
|
||||
expect(twentyTwo).to.be(22)
|
||||
return 11
|
||||
})
|
||||
promise.then(function(twentyTwo) {
|
||||
expect(called++).to.be(1)
|
||||
expect(twentyTwo).to.be(22)
|
||||
return 11
|
||||
})
|
||||
promise.then(function(twentyTwo) {
|
||||
expect(called++).to.be(2)
|
||||
expect(twentyTwo).to.be(22)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('supports early deferreds', function(done){
|
||||
|
||||
|
||||
var promise = testPromise()
|
||||
|
||||
function earlyDefer() {
|
||||
var deferred = new Promise().resolve(33)
|
||||
return deferred
|
||||
}
|
||||
|
||||
promise.then(function(){
|
||||
return earlyDefer()
|
||||
}).then(function(thirtyThree){
|
||||
expect(thirtyThree).to.be(33)
|
||||
}).then(earlyDefer).then(function(thirtyThree){
|
||||
expect(thirtyThree).to.be(33)
|
||||
done()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
it('basic error deferred', function (done) {
|
||||
function errDefer() {
|
||||
var deferred = new Promise(function (resolve, reject) {
|
||||
process.nextTick(function(){
|
||||
reject(new Error('abc'))
|
||||
})
|
||||
})
|
||||
return deferred
|
||||
}
|
||||
|
||||
errDefer().then(function () {
|
||||
done(new Error('then recieved an error'))
|
||||
}, function (err) {
|
||||
expect(err.message).to.be('abc')
|
||||
}).then(function () {
|
||||
throw new Error('abc')
|
||||
}).then(null, function (err) {
|
||||
expect(err.message).to.be('abc')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('supports error deferreds', function(done){
|
||||
function errDefer() {
|
||||
var deferred = new Promise(function (resolve, reject) {
|
||||
process.nextTick(function(){
|
||||
reject(new Error('abc'))
|
||||
})
|
||||
})
|
||||
return deferred
|
||||
}
|
||||
|
||||
var promise = testPromise()
|
||||
|
||||
|
||||
promise.then(errDefer).then(function(){
|
||||
// This should not be called
|
||||
done(new Error('then recieved an error'))
|
||||
}).then(null, function(err) {
|
||||
expect(err.message).to.be('abc')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('supports early error deferreds', function(done){
|
||||
var promise = testPromise()
|
||||
|
||||
function earlyErr() {
|
||||
var deferred = new Promise()
|
||||
deferred.reject(new Error('def'))
|
||||
return deferred
|
||||
}
|
||||
|
||||
promise.then(function(){
|
||||
return earlyErr()
|
||||
}).then(function() {
|
||||
// This should not be called
|
||||
done(new Error('then recieved an error'))
|
||||
}).then(null, function(err) {
|
||||
expect(err.message).to.be('def')
|
||||
}).then(null, function(err){
|
||||
done(new Error('exception transcended a fail'))
|
||||
}).then(function(){
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('supports double resolves', function(done) {
|
||||
var promise = testPromise()
|
||||
|
||||
function doubleResolve() {
|
||||
var deferred = new Promise()
|
||||
deferred.resolve(66)
|
||||
deferred.resolve(99)
|
||||
return deferred
|
||||
}
|
||||
|
||||
promise.then(doubleResolve).then(function(sixtySix){
|
||||
expect(sixtySix).to.be(66)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('supports double rejects', function(done) {
|
||||
var promise = testPromise()
|
||||
|
||||
function doubleReject() {
|
||||
var deferred = new Promise(function (resolve, reject) {
|
||||
reject(new Error('abc'))
|
||||
reject(new Error('def'))
|
||||
})
|
||||
return deferred
|
||||
}
|
||||
|
||||
promise.then(doubleReject).then(null, function(abc){
|
||||
expect(abc.message).to.be('abc')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('isnt called twice', function (done) {
|
||||
var p1 = new Promise(function (resolve) {
|
||||
resolve(1)
|
||||
})
|
||||
|
||||
p1.then(function (r1) {
|
||||
r1.should.be(1)
|
||||
setTimeout(function () {
|
||||
done()
|
||||
}, 10)
|
||||
}).catch(function (e) {
|
||||
done(new Error())
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe('error handling', function(){
|
||||
|
||||
function errDefer() {
|
||||
var deferred = new Promise()
|
||||
process.nextTick(function(){
|
||||
deferred.reject(new Error('abc'))
|
||||
})
|
||||
return deferred
|
||||
}
|
||||
|
||||
|
||||
it('handles basic errors properly', function(done) {
|
||||
var promise = errDefer()
|
||||
|
||||
promise.then(function(err){
|
||||
console.log('errr', err)
|
||||
done(new Error('then recieved an error'))
|
||||
}).then(null, function(err){
|
||||
expect(err.message).to.be('abc')
|
||||
}).then(null, function(){
|
||||
done(new Error('then recieved an error'))
|
||||
}).then(null, function(){
|
||||
done(new Error('then recieved an error'))
|
||||
}).then(function(){
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('handles async errors properly', function(done){
|
||||
var promise = errDefer()
|
||||
promise.then(null, function(){
|
||||
return errDefer().then(null, function(){
|
||||
return 11
|
||||
})
|
||||
}).then(function(eleven) {
|
||||
expect(eleven).to.be(11)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('supports second `then` argument properly', function(done) {
|
||||
var promise = errDefer()
|
||||
promise.then(null, function(){
|
||||
return 1
|
||||
}).then(function(){
|
||||
throw new Error('def')
|
||||
}).then(null, function(err) {
|
||||
expect(err.message).to.be('def')
|
||||
return 99
|
||||
}).then(function(ninetyNine){
|
||||
expect(ninetyNine).to.be(99)
|
||||
return errDefer().then(null, function(){
|
||||
return 44
|
||||
})
|
||||
}).then(function(fortyFour){
|
||||
expect(fortyFour).to.be(44)
|
||||
throw new Error('ghi')
|
||||
}).then(null, function(err){
|
||||
expect(err.message).to.be('ghi')
|
||||
}).then(function(err) {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects internal trhow', function (done) {
|
||||
var p = new Promise(function (resolve, reject) {
|
||||
throw new Error('abc')
|
||||
})
|
||||
|
||||
p.then(function () {
|
||||
done(new Error('then recieved an error'))
|
||||
}, function (err) {
|
||||
expect(err.message).to.be('abc')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user