Browse Source

修改密码

jw-featrue-zhanlibiao
mk 2 years ago
parent
commit
05c3c2e299
  1. 3
      app.json
  2. BIN
      images/card.png
  3. BIN
      images/login/right_bg.png
  4. BIN
      images/message/header_bg.jpg
  5. BIN
      images/statistics/hx_bg.png
  6. BIN
      images/work/bg.png
  7. BIN
      images/work/card.png
  8. BIN
      images/work/center.png
  9. BIN
      images/work/map.png
  10. BIN
      images/work/messageBg.png
  11. BIN
      images/work/shareBg.png
  12. BIN
      images/work/sqmp.png
  13. 116
      libs/jsencrypt/lib/JSEncrypt.d.ts
  14. 192
      libs/jsencrypt/lib/JSEncrypt.js
  15. 142
      libs/jsencrypt/lib/JSEncryptRSAKey.d.ts
  16. 320
      libs/jsencrypt/lib/JSEncryptRSAKey.js
  17. 3
      libs/jsencrypt/lib/index.d.ts
  18. 3
      libs/jsencrypt/lib/index.js
  19. 51
      libs/jsencrypt/lib/lib/asn1js/asn1.d.ts
  20. 565
      libs/jsencrypt/lib/lib/asn1js/asn1.js
  21. 5
      libs/jsencrypt/lib/lib/asn1js/base64.d.ts
  22. 88
      libs/jsencrypt/lib/lib/asn1js/base64.js
  23. 3
      libs/jsencrypt/lib/lib/asn1js/hex.d.ts
  24. 64
      libs/jsencrypt/lib/lib/asn1js/hex.js
  25. 9
      libs/jsencrypt/lib/lib/asn1js/int10.d.ts
  26. 87
      libs/jsencrypt/lib/lib/asn1js/int10.js
  27. 9778
      libs/jsencrypt/lib/lib/asn1js/oids.d.ts
  28. 1962
      libs/jsencrypt/lib/lib/asn1js/oids.js
  29. 3
      libs/jsencrypt/lib/lib/jsbn/base64.d.ts
  30. 76
      libs/jsencrypt/lib/lib/jsbn/base64.js
  31. 98
      libs/jsencrypt/lib/lib/jsbn/jsbn.d.ts
  32. 1754
      libs/jsencrypt/lib/lib/jsbn/jsbn.js
  33. 10
      libs/jsencrypt/lib/lib/jsbn/prng4.d.ts
  34. 46
      libs/jsencrypt/lib/lib/jsbn/prng4.js
  35. 3
      libs/jsencrypt/lib/lib/jsbn/rng.d.ts
  36. 78
      libs/jsencrypt/lib/lib/jsbn/rng.js
  37. 23
      libs/jsencrypt/lib/lib/jsbn/rsa.d.ts
  38. 373
      libs/jsencrypt/lib/lib/jsbn/rsa.js
  39. 7
      libs/jsencrypt/lib/lib/jsbn/util.d.ts
  40. 58
      libs/jsencrypt/lib/lib/jsbn/util.js
  41. 1593
      libs/jsencrypt/lib/lib/jsrsasign/asn1-1.0.js
  42. 69
      libs/jsencrypt/lib/lib/jsrsasign/yahoo.js
  43. 1
      libs/jsencrypt/lib/version.json
  44. 34
      pages/index/index.js
  45. 4
      pages/index/index.wxml
  46. 7
      project.private.config.json
  47. 404
      subpages/addResi/pages/addResi/addResi.js
  48. 278
      subpages/addhouse/pages/addhouse/addhouse.js
  49. 4
      subpages/communitySelfInsp/pages/followUpDetail/followUpDetail.js
  50. 4
      subpages/communitySelfInsp/pages/followUpDetail/followUpDetail.wxml
  51. 163
      subpages/settings/pages/changePassword/changePassword.js
  52. 4
      subpages/settings/pages/changePassword/changePassword.json
  53. 23
      subpages/settings/pages/changePassword/changePassword.wxml
  54. 50
      subpages/settings/pages/changePassword/changePassword.wxss
  55. 5
      subpages/settings/pages/index/index.js
  56. 2
      subpages/settings/pages/index/index.wxml
  57. 17
      utils/api.js
  58. 6
      utils/config.js
  59. 11
      utils/index.js
  60. 1
      utils/util.js

3
app.json

@ -79,7 +79,8 @@
"root": "subpages/settings",
"name": "settings",
"pages": [
"pages/index/index"
"pages/index/index",
"pages/changePassword/changePassword"
]
}
],

BIN
images/card.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 17 KiB

BIN
images/login/right_bg.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

BIN
images/message/header_bg.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 27 KiB

BIN
images/statistics/hx_bg.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/work/bg.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 24 KiB

BIN
images/work/card.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
images/work/center.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 31 KiB

BIN
images/work/map.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 20 KiB

BIN
images/work/messageBg.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
images/work/shareBg.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 28 KiB

BIN
images/work/sqmp.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 35 KiB

116
libs/jsencrypt/lib/JSEncrypt.d.ts

@ -0,0 +1,116 @@
import { JSEncryptRSAKey } from "./JSEncryptRSAKey";
export interface IJSEncryptOptions {
default_key_size?: string;
default_public_exponent?: string;
log?: boolean;
}
/**
*
* @param {Object} [options = {}] - An object to customize JSEncrypt behaviour
* possible parameters are:
* - default_key_size {number} default: 1024 the key size in bit
* - default_public_exponent {string} default: '010001' the hexadecimal representation of the public exponent
* - log {boolean} default: false whether log warn/error or not
* @constructor
*/
export declare class JSEncrypt {
constructor(options?: IJSEncryptOptions);
private default_key_size;
private default_public_exponent;
private log;
private key;
static version: string;
/**
* Method to set the rsa key parameter (one method is enough to set both the public
* and the private key, since the private key contains the public key paramenters)
* Log a warning if logs are enabled
* @param {Object|string} key the pem encoded string or an object (with or without header/footer)
* @public
*/
setKey(key: string): void;
/**
* Proxy method for setKey, for api compatibility
* @see setKey
* @public
*/
setPrivateKey(privkey: string): void;
/**
* Proxy method for setKey, for api compatibility
* @see setKey
* @public
*/
setPublicKey(pubkey: string): void;
/**
* Proxy method for RSAKey object's decrypt, decrypt the string using the private
* components of the rsa key object. Note that if the object was not set will be created
* on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
* @param {string} str base64 encoded crypted string to decrypt
* @return {string} the decrypted string
* @public
*/
decrypt(str: string): string | false;
/**
* Proxy method for RSAKey object's encrypt, encrypt the string using the public
* components of the rsa key object. Note that if the object was not set will be created
* on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
* @param {string} str the string to encrypt
* @return {string} the encrypted string encoded in base64
* @public
*/
encrypt(str: string): string | false;
/**
* Proxy method for RSAKey object's sign.
* @param {string} str the string to sign
* @param {function} digestMethod hash method
* @param {string} digestName the name of the hash algorithm
* @return {string} the signature encoded in base64
* @public
*/
sign(str: string, digestMethod: (str: string) => string, digestName: string): string | false;
/**
* Proxy method for RSAKey object's verify.
* @param {string} str the string to verify
* @param {string} signature the signature encoded in base64 to compare the string to
* @param {function} digestMethod hash method
* @return {boolean} whether the data and signature match
* @public
*/
verify(str: string, signature: string, digestMethod: (str: string) => string): boolean;
/**
* Getter for the current JSEncryptRSAKey object. If it doesn't exists a new object
* will be created and returned
* @param {callback} [cb] the callback to be called if we want the key to be generated
* in an async fashion
* @returns {JSEncryptRSAKey} the JSEncryptRSAKey object
* @public
*/
getKey(cb?: () => void): JSEncryptRSAKey;
/**
* Returns the pem encoded representation of the private key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the private key WITH header and footer
* @public
*/
getPrivateKey(): string;
/**
* Returns the pem encoded representation of the private key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the private key WITHOUT header and footer
* @public
*/
getPrivateKeyB64(): string;
/**
* Returns the pem encoded representation of the public key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the public key WITH header and footer
* @public
*/
getPublicKey(): string;
/**
* Returns the pem encoded representation of the public key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the public key WITHOUT header and footer
* @public
*/
getPublicKeyB64(): string;
}

192
libs/jsencrypt/lib/JSEncrypt.js

@ -0,0 +1,192 @@
var _a;
import { b64tohex, hex2b64 } from "./lib/jsbn/base64";
import { JSEncryptRSAKey } from "./JSEncryptRSAKey";
var version = typeof process !== 'undefined'
? (_a = process.env) === null || _a === void 0 ? void 0 : _a.npm_package_version
: undefined;
/**
*
* @param {Object} [options = {}] - An object to customize JSEncrypt behaviour
* possible parameters are:
* - default_key_size {number} default: 1024 the key size in bit
* - default_public_exponent {string} default: '010001' the hexadecimal representation of the public exponent
* - log {boolean} default: false whether log warn/error or not
* @constructor
*/
var JSEncrypt = /** @class */ (function () {
function JSEncrypt(options) {
if (options === void 0) { options = {}; }
options = options || {};
this.default_key_size = options.default_key_size
? parseInt(options.default_key_size, 10)
: 1024;
this.default_public_exponent = options.default_public_exponent || "010001"; // 65537 default openssl public exponent for rsa key type
this.log = options.log || false;
// The private and public key.
this.key = null;
}
/**
* Method to set the rsa key parameter (one method is enough to set both the public
* and the private key, since the private key contains the public key paramenters)
* Log a warning if logs are enabled
* @param {Object|string} key the pem encoded string or an object (with or without header/footer)
* @public
*/
JSEncrypt.prototype.setKey = function (key) {
if (this.log && this.key) {
console.warn("A key was already set, overriding existing.");
}
this.key = new JSEncryptRSAKey(key);
};
/**
* Proxy method for setKey, for api compatibility
* @see setKey
* @public
*/
JSEncrypt.prototype.setPrivateKey = function (privkey) {
// Create the key.
this.setKey(privkey);
};
/**
* Proxy method for setKey, for api compatibility
* @see setKey
* @public
*/
JSEncrypt.prototype.setPublicKey = function (pubkey) {
// Sets the public key.
this.setKey(pubkey);
};
/**
* Proxy method for RSAKey object's decrypt, decrypt the string using the private
* components of the rsa key object. Note that if the object was not set will be created
* on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
* @param {string} str base64 encoded crypted string to decrypt
* @return {string} the decrypted string
* @public
*/
JSEncrypt.prototype.decrypt = function (str) {
// Return the decrypted string.
try {
return this.getKey().decrypt(b64tohex(str));
}
catch (ex) {
return false;
}
};
/**
* Proxy method for RSAKey object's encrypt, encrypt the string using the public
* components of the rsa key object. Note that if the object was not set will be created
* on the fly (by the getKey method) using the parameters passed in the JSEncrypt constructor
* @param {string} str the string to encrypt
* @return {string} the encrypted string encoded in base64
* @public
*/
JSEncrypt.prototype.encrypt = function (str) {
// Return the encrypted string.
try {
return hex2b64(this.getKey().encrypt(str));
}
catch (ex) {
return false;
}
};
/**
* Proxy method for RSAKey object's sign.
* @param {string} str the string to sign
* @param {function} digestMethod hash method
* @param {string} digestName the name of the hash algorithm
* @return {string} the signature encoded in base64
* @public
*/
JSEncrypt.prototype.sign = function (str, digestMethod, digestName) {
// return the RSA signature of 'str' in 'hex' format.
try {
return hex2b64(this.getKey().sign(str, digestMethod, digestName));
}
catch (ex) {
return false;
}
};
/**
* Proxy method for RSAKey object's verify.
* @param {string} str the string to verify
* @param {string} signature the signature encoded in base64 to compare the string to
* @param {function} digestMethod hash method
* @return {boolean} whether the data and signature match
* @public
*/
JSEncrypt.prototype.verify = function (str, signature, digestMethod) {
// Return the decrypted 'digest' of the signature.
try {
return this.getKey().verify(str, b64tohex(signature), digestMethod);
}
catch (ex) {
return false;
}
};
/**
* Getter for the current JSEncryptRSAKey object. If it doesn't exists a new object
* will be created and returned
* @param {callback} [cb] the callback to be called if we want the key to be generated
* in an async fashion
* @returns {JSEncryptRSAKey} the JSEncryptRSAKey object
* @public
*/
JSEncrypt.prototype.getKey = function (cb) {
// Only create new if it does not exist.
if (!this.key) {
// Get a new private key.
this.key = new JSEncryptRSAKey();
if (cb && {}.toString.call(cb) === "[object Function]") {
this.key.generateAsync(this.default_key_size, this.default_public_exponent, cb);
return;
}
// Generate the key.
this.key.generate(this.default_key_size, this.default_public_exponent);
}
return this.key;
};
/**
* Returns the pem encoded representation of the private key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the private key WITH header and footer
* @public
*/
JSEncrypt.prototype.getPrivateKey = function () {
// Return the private representation of this key.
return this.getKey().getPrivateKey();
};
/**
* Returns the pem encoded representation of the private key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the private key WITHOUT header and footer
* @public
*/
JSEncrypt.prototype.getPrivateKeyB64 = function () {
// Return the private representation of this key.
return this.getKey().getPrivateBaseKeyB64();
};
/**
* Returns the pem encoded representation of the public key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the public key WITH header and footer
* @public
*/
JSEncrypt.prototype.getPublicKey = function () {
// Return the private representation of this key.
return this.getKey().getPublicKey();
};
/**
* Returns the pem encoded representation of the public key
* If the key doesn't exists a new key will be created
* @returns {string} pem encoded representation of the public key WITHOUT header and footer
* @public
*/
JSEncrypt.prototype.getPublicKeyB64 = function () {
// Return the private representation of this key.
return this.getKey().getPublicBaseKeyB64();
};
JSEncrypt.version = version;
return JSEncrypt;
}());
export { JSEncrypt };

142
libs/jsencrypt/lib/JSEncryptRSAKey.d.ts

@ -0,0 +1,142 @@
import { RSAKey } from "./lib/jsbn/rsa";
/**
* Create a new JSEncryptRSAKey that extends Tom Wu's RSA key object.
* This object is just a decorator for parsing the key parameter
* @param {string|Object} key - The key in string format, or an object containing
* the parameters needed to build a RSAKey object.
* @constructor
*/
export declare class JSEncryptRSAKey extends RSAKey {
constructor(key?: string);
/**
* Method to parse a pem encoded string containing both a public or private key.
* The method will translate the pem encoded string in a der encoded string and
* will parse private key and public key parameters. This method accepts public key
* in the rsaencryption pkcs #1 format (oid: 1.2.840.113549.1.1.1).
*
* @todo Check how many rsa formats use the same format of pkcs #1.
*
* The format is defined as:
* PublicKeyInfo ::= SEQUENCE {
* algorithm AlgorithmIdentifier,
* PublicKey BIT STRING
* }
* Where AlgorithmIdentifier is:
* AlgorithmIdentifier ::= SEQUENCE {
* algorithm OBJECT IDENTIFIER, the OID of the enc algorithm
* parameters ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
* }
* and PublicKey is a SEQUENCE encapsulated in a BIT STRING
* RSAPublicKey ::= SEQUENCE {
* modulus INTEGER, -- n
* publicExponent INTEGER -- e
* }
* it's possible to examine the structure of the keys obtained from openssl using
* an asn.1 dumper as the one used here to parse the components: http://lapo.it/asn1js/
* @argument {string} pem the pem encoded string, can include the BEGIN/END header/footer
* @private
*/
parseKey(pem: string): boolean;
/**
* Translate rsa parameters in a hex encoded string representing the rsa key.
*
* The translation follow the ASN.1 notation :
* RSAPrivateKey ::= SEQUENCE {
* version Version,
* modulus INTEGER, -- n
* publicExponent INTEGER, -- e
* privateExponent INTEGER, -- d
* prime1 INTEGER, -- p
* prime2 INTEGER, -- q
* exponent1 INTEGER, -- d mod (p1)
* exponent2 INTEGER, -- d mod (q-1)
* coefficient INTEGER, -- (inverse of q) mod p
* }
* @returns {string} DER Encoded String representing the rsa private key
* @private
*/
getPrivateBaseKey(): string;
/**
* base64 (pem) encoded version of the DER encoded representation
* @returns {string} pem encoded representation without header and footer
* @public
*/
getPrivateBaseKeyB64(): string;
/**
* Translate rsa parameters in a hex encoded string representing the rsa public key.
* The representation follow the ASN.1 notation :
* PublicKeyInfo ::= SEQUENCE {
* algorithm AlgorithmIdentifier,
* PublicKey BIT STRING
* }
* Where AlgorithmIdentifier is:
* AlgorithmIdentifier ::= SEQUENCE {
* algorithm OBJECT IDENTIFIER, the OID of the enc algorithm
* parameters ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
* }
* and PublicKey is a SEQUENCE encapsulated in a BIT STRING
* RSAPublicKey ::= SEQUENCE {
* modulus INTEGER, -- n
* publicExponent INTEGER -- e
* }
* @returns {string} DER Encoded String representing the rsa public key
* @private
*/
getPublicBaseKey(): string;
/**
* base64 (pem) encoded version of the DER encoded representation
* @returns {string} pem encoded representation without header and footer
* @public
*/
getPublicBaseKeyB64(): string;
/**
* wrap the string in block of width chars. The default value for rsa keys is 64
* characters.
* @param {string} str the pem encoded string without header and footer
* @param {Number} [width=64] - the length the string has to be wrapped at
* @returns {string}
* @private
*/
static wordwrap(str: string, width?: number): string;
/**
* Retrieve the pem encoded private key
* @returns {string} the pem encoded private key with header/footer
* @public
*/
getPrivateKey(): string;
/**
* Retrieve the pem encoded public key
* @returns {string} the pem encoded public key with header/footer
* @public
*/
getPublicKey(): string;
/**
* Check if the object contains the necessary parameters to populate the rsa modulus
* and public exponent parameters.
* @param {Object} [obj={}] - An object that may contain the two public key
* parameters
* @returns {boolean} true if the object contains both the modulus and the public exponent
* properties (n and e)
* @todo check for types of n and e. N should be a parseable bigInt object, E should
* be a parseable integer number
* @private
*/
static hasPublicKeyProperty(obj: object): boolean;
/**
* Check if the object contains ALL the parameters of an RSA key.
* @param {Object} [obj={}] - An object that may contain nine rsa key
* parameters
* @returns {boolean} true if the object contains all the parameters needed
* @todo check for types of the parameters all the parameters but the public exponent
* should be parseable bigint objects, the public exponent should be a parseable integer number
* @private
*/
static hasPrivateKeyProperty(obj: object): boolean;
/**
* Parse the properties of obj in the current rsa object. Obj should AT LEAST
* include the modulus and public exponent (n, e) parameters.
* @param {Object} obj - the object containing rsa parameters
* @private
*/
parsePropertiesFrom(obj: any): void;
}

320
libs/jsencrypt/lib/JSEncryptRSAKey.js

@ -0,0 +1,320 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { hex2b64 } from "./lib/jsbn/base64";
import { Hex } from "./lib/asn1js/hex";
import { Base64 } from "./lib/asn1js/base64";
import { ASN1 } from "./lib/asn1js/asn1";
import { RSAKey } from "./lib/jsbn/rsa";
import { parseBigInt } from "./lib/jsbn/jsbn";
import { KJUR } from "./lib/jsrsasign/asn1-1.0";
/**
* Create a new JSEncryptRSAKey that extends Tom Wu's RSA key object.
* This object is just a decorator for parsing the key parameter
* @param {string|Object} key - The key in string format, or an object containing
* the parameters needed to build a RSAKey object.
* @constructor
*/
var JSEncryptRSAKey = /** @class */ (function (_super) {
__extends(JSEncryptRSAKey, _super);
function JSEncryptRSAKey(key) {
var _this = _super.call(this) || this;
// Call the super constructor.
// RSAKey.call(this);
// If a key key was provided.
if (key) {
// If this is a string...
if (typeof key === "string") {
_this.parseKey(key);
}
else if (JSEncryptRSAKey.hasPrivateKeyProperty(key) ||
JSEncryptRSAKey.hasPublicKeyProperty(key)) {
// Set the values for the key.
_this.parsePropertiesFrom(key);
}
}
return _this;
}
/**
* Method to parse a pem encoded string containing both a public or private key.
* The method will translate the pem encoded string in a der encoded string and
* will parse private key and public key parameters. This method accepts public key
* in the rsaencryption pkcs #1 format (oid: 1.2.840.113549.1.1.1).
*
* @todo Check how many rsa formats use the same format of pkcs #1.
*
* The format is defined as:
* PublicKeyInfo ::= SEQUENCE {
* algorithm AlgorithmIdentifier,
* PublicKey BIT STRING
* }
* Where AlgorithmIdentifier is:
* AlgorithmIdentifier ::= SEQUENCE {
* algorithm OBJECT IDENTIFIER, the OID of the enc algorithm
* parameters ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
* }
* and PublicKey is a SEQUENCE encapsulated in a BIT STRING
* RSAPublicKey ::= SEQUENCE {
* modulus INTEGER, -- n
* publicExponent INTEGER -- e
* }
* it's possible to examine the structure of the keys obtained from openssl using
* an asn.1 dumper as the one used here to parse the components: http://lapo.it/asn1js/
* @argument {string} pem the pem encoded string, can include the BEGIN/END header/footer
* @private
*/
JSEncryptRSAKey.prototype.parseKey = function (pem) {
try {
var modulus = 0;
var public_exponent = 0;
var reHex = /^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/;
var der = reHex.test(pem) ? Hex.decode(pem) : Base64.unarmor(pem);
var asn1 = ASN1.decode(der);
// Fixes a bug with OpenSSL 1.0+ private keys
if (asn1.sub.length === 3) {
asn1 = asn1.sub[2].sub[0];
}
if (asn1.sub.length === 9) {
// Parse the private key.
modulus = asn1.sub[1].getHexStringValue(); // bigint
this.n = parseBigInt(modulus, 16);
public_exponent = asn1.sub[2].getHexStringValue(); // int
this.e = parseInt(public_exponent, 16);
var private_exponent = asn1.sub[3].getHexStringValue(); // bigint
this.d = parseBigInt(private_exponent, 16);
var prime1 = asn1.sub[4].getHexStringValue(); // bigint
this.p = parseBigInt(prime1, 16);
var prime2 = asn1.sub[5].getHexStringValue(); // bigint
this.q = parseBigInt(prime2, 16);
var exponent1 = asn1.sub[6].getHexStringValue(); // bigint
this.dmp1 = parseBigInt(exponent1, 16);
var exponent2 = asn1.sub[7].getHexStringValue(); // bigint
this.dmq1 = parseBigInt(exponent2, 16);
var coefficient = asn1.sub[8].getHexStringValue(); // bigint
this.coeff = parseBigInt(coefficient, 16);
}
else if (asn1.sub.length === 2) {
if (asn1.sub[0].sub) {
// Parse ASN.1 SubjectPublicKeyInfo type as defined by X.509
var bit_string = asn1.sub[1];
var sequence = bit_string.sub[0];
modulus = sequence.sub[0].getHexStringValue();
this.n = parseBigInt(modulus, 16);
public_exponent = sequence.sub[1].getHexStringValue();
this.e = parseInt(public_exponent, 16);
}
else {
// Parse ASN.1 RSAPublicKey type as defined by PKCS #1
modulus = asn1.sub[0].getHexStringValue();
this.n = parseBigInt(modulus, 16);
public_exponent = asn1.sub[1].getHexStringValue();
this.e = parseInt(public_exponent, 16);
}
}
else {
return false;
}
return true;
}
catch (ex) {
return false;
}
};
/**
* Translate rsa parameters in a hex encoded string representing the rsa key.
*
* The translation follow the ASN.1 notation :
* RSAPrivateKey ::= SEQUENCE {
* version Version,
* modulus INTEGER, -- n
* publicExponent INTEGER, -- e
* privateExponent INTEGER, -- d
* prime1 INTEGER, -- p
* prime2 INTEGER, -- q
* exponent1 INTEGER, -- d mod (p1)
* exponent2 INTEGER, -- d mod (q-1)
* coefficient INTEGER, -- (inverse of q) mod p
* }
* @returns {string} DER Encoded String representing the rsa private key
* @private
*/
JSEncryptRSAKey.prototype.getPrivateBaseKey = function () {
var options = {
array: [
new KJUR.asn1.DERInteger({ int: 0 }),
new KJUR.asn1.DERInteger({ bigint: this.n }),
new KJUR.asn1.DERInteger({ int: this.e }),
new KJUR.asn1.DERInteger({ bigint: this.d }),
new KJUR.asn1.DERInteger({ bigint: this.p }),
new KJUR.asn1.DERInteger({ bigint: this.q }),
new KJUR.asn1.DERInteger({ bigint: this.dmp1 }),
new KJUR.asn1.DERInteger({ bigint: this.dmq1 }),
new KJUR.asn1.DERInteger({ bigint: this.coeff }),
],
};
var seq = new KJUR.asn1.DERSequence(options);
return seq.getEncodedHex();
};
/**
* base64 (pem) encoded version of the DER encoded representation
* @returns {string} pem encoded representation without header and footer
* @public
*/
JSEncryptRSAKey.prototype.getPrivateBaseKeyB64 = function () {
return hex2b64(this.getPrivateBaseKey());
};
/**
* Translate rsa parameters in a hex encoded string representing the rsa public key.
* The representation follow the ASN.1 notation :
* PublicKeyInfo ::= SEQUENCE {
* algorithm AlgorithmIdentifier,
* PublicKey BIT STRING
* }
* Where AlgorithmIdentifier is:
* AlgorithmIdentifier ::= SEQUENCE {
* algorithm OBJECT IDENTIFIER, the OID of the enc algorithm
* parameters ANY DEFINED BY algorithm OPTIONAL (NULL for PKCS #1)
* }
* and PublicKey is a SEQUENCE encapsulated in a BIT STRING
* RSAPublicKey ::= SEQUENCE {
* modulus INTEGER, -- n
* publicExponent INTEGER -- e
* }
* @returns {string} DER Encoded String representing the rsa public key
* @private
*/
JSEncryptRSAKey.prototype.getPublicBaseKey = function () {
var first_sequence = new KJUR.asn1.DERSequence({
array: [
new KJUR.asn1.DERObjectIdentifier({ oid: "1.2.840.113549.1.1.1" }),
new KJUR.asn1.DERNull(),
],
});
var second_sequence = new KJUR.asn1.DERSequence({
array: [
new KJUR.asn1.DERInteger({ bigint: this.n }),
new KJUR.asn1.DERInteger({ int: this.e }),
],
});
var bit_string = new KJUR.asn1.DERBitString({
hex: "00" + second_sequence.getEncodedHex(),
});
var seq = new KJUR.asn1.DERSequence({
array: [first_sequence, bit_string],
});
return seq.getEncodedHex();
};
/**
* base64 (pem) encoded version of the DER encoded representation
* @returns {string} pem encoded representation without header and footer
* @public
*/
JSEncryptRSAKey.prototype.getPublicBaseKeyB64 = function () {
return hex2b64(this.getPublicBaseKey());
};
/**
* wrap the string in block of width chars. The default value for rsa keys is 64
* characters.
* @param {string} str the pem encoded string without header and footer
* @param {Number} [width=64] - the length the string has to be wrapped at
* @returns {string}
* @private
*/
JSEncryptRSAKey.wordwrap = function (str, width) {
width = width || 64;
if (!str) {
return str;
}
var regex = "(.{1," + width + "})( +|$\n?)|(.{1," + width + "})";
return str.match(RegExp(regex, "g")).join("\n");
};
/**
* Retrieve the pem encoded private key
* @returns {string} the pem encoded private key with header/footer
* @public
*/
JSEncryptRSAKey.prototype.getPrivateKey = function () {
var key = "-----BEGIN RSA PRIVATE KEY-----\n";
key += JSEncryptRSAKey.wordwrap(this.getPrivateBaseKeyB64()) + "\n";
key += "-----END RSA PRIVATE KEY-----";
return key;
};
/**
* Retrieve the pem encoded public key
* @returns {string} the pem encoded public key with header/footer
* @public
*/
JSEncryptRSAKey.prototype.getPublicKey = function () {
var key = "-----BEGIN PUBLIC KEY-----\n";
key += JSEncryptRSAKey.wordwrap(this.getPublicBaseKeyB64()) + "\n";
key += "-----END PUBLIC KEY-----";
return key;
};
/**
* Check if the object contains the necessary parameters to populate the rsa modulus
* and public exponent parameters.
* @param {Object} [obj={}] - An object that may contain the two public key
* parameters
* @returns {boolean} true if the object contains both the modulus and the public exponent
* properties (n and e)
* @todo check for types of n and e. N should be a parseable bigInt object, E should
* be a parseable integer number
* @private
*/
JSEncryptRSAKey.hasPublicKeyProperty = function (obj) {
obj = obj || {};
return obj.hasOwnProperty("n") && obj.hasOwnProperty("e");
};
/**
* Check if the object contains ALL the parameters of an RSA key.
* @param {Object} [obj={}] - An object that may contain nine rsa key
* parameters
* @returns {boolean} true if the object contains all the parameters needed
* @todo check for types of the parameters all the parameters but the public exponent
* should be parseable bigint objects, the public exponent should be a parseable integer number
* @private
*/
JSEncryptRSAKey.hasPrivateKeyProperty = function (obj) {
obj = obj || {};
return (obj.hasOwnProperty("n") &&
obj.hasOwnProperty("e") &&
obj.hasOwnProperty("d") &&
obj.hasOwnProperty("p") &&
obj.hasOwnProperty("q") &&
obj.hasOwnProperty("dmp1") &&
obj.hasOwnProperty("dmq1") &&
obj.hasOwnProperty("coeff"));
};
/**
* Parse the properties of obj in the current rsa object. Obj should AT LEAST
* include the modulus and public exponent (n, e) parameters.
* @param {Object} obj - the object containing rsa parameters
* @private
*/
JSEncryptRSAKey.prototype.parsePropertiesFrom = function (obj) {
this.n = obj.n;
this.e = obj.e;
if (obj.hasOwnProperty("d")) {
this.d = obj.d;
this.p = obj.p;
this.q = obj.q;
this.dmp1 = obj.dmp1;
this.dmq1 = obj.dmq1;
this.coeff = obj.coeff;
}
};
return JSEncryptRSAKey;
}(RSAKey));
export { JSEncryptRSAKey };

3
libs/jsencrypt/lib/index.d.ts

@ -0,0 +1,3 @@
import { JSEncrypt } from './JSEncrypt';
export { JSEncrypt };
export default JSEncrypt;

3
libs/jsencrypt/lib/index.js

@ -0,0 +1,3 @@
import { JSEncrypt } from './JSEncrypt';
export { JSEncrypt };
export default JSEncrypt;

51
libs/jsencrypt/lib/lib/asn1js/asn1.d.ts

@ -0,0 +1,51 @@
import { Int10 } from "./int10";
export declare class Stream {
constructor(enc: Stream | number[], pos?: number);
private enc;
pos: number;
get(pos?: number): number;
hexDigits: string;
hexByte(b: number): string;
hexDump(start: number, end: number, raw: boolean): string;
isASCII(start: number, end: number): boolean;
parseStringISO(start: number, end: number): string;
parseStringUTF(start: number, end: number): string;
parseStringBMP(start: number, end: number): string;
parseTime(start: number, end: number, shortYear: boolean): string;
parseInteger(start: number, end: number): string | 0 | -1;
parseBitString(start: number, end: number, maxLength: number): string;
parseOctetString(start: number, end: number, maxLength: number): string;
parseOID(start: number, end: number, maxLength: number): string;
}
export declare class ASN1 {
constructor(stream: Stream, header: number, length: number, tag: ASN1Tag, sub: ASN1[]);
private stream;
private header;
private length;
private tag;
sub: ASN1[];
typeName(): string;
content(maxLength: number): string | 0 | -1;
toString(): string;
toPrettyString(indent: string): string;
posStart(): number;
posContent(): number;
posEnd(): number;
toHexString(): string;
static decodeLength(stream: Stream): number;
/**
* Retrieve the hexadecimal value (as a string) of the current ASN.1 element
* @returns {string}
* @public
*/
getHexStringValue(): string;
static decode(str: Stream | number[]): ASN1;
}
export declare class ASN1Tag {
constructor(stream: Stream);
tagClass: number;
tagConstructed: boolean;
tagNumber: number | Int10;
isUniversal(): boolean;
isEOC(): boolean;
}

565
libs/jsencrypt/lib/lib/asn1js/asn1.js

@ -0,0 +1,565 @@
// ASN.1 JavaScript decoder
// Copyright (c) 2008-2014 Lapo Luchini <lapo@lapo.it>
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
/*global oids */
import { Int10 } from "./int10";
var ellipsis = "\u2026";
var reTimeS = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
var reTimeL = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;
function stringCut(str, len) {
if (str.length > len) {
str = str.substring(0, len) + ellipsis;
}
return str;
}
var Stream = /** @class */ (function () {
function Stream(enc, pos) {
this.hexDigits = "0123456789ABCDEF";
if (enc instanceof Stream) {
this.enc = enc.enc;
this.pos = enc.pos;
}
else {
// enc should be an array or a binary string
this.enc = enc;
this.pos = pos;
}
}
Stream.prototype.get = function (pos) {
if (pos === undefined) {
pos = this.pos++;
}
if (pos >= this.enc.length) {
throw new Error("Requesting byte offset ".concat(pos, " on a stream of length ").concat(this.enc.length));
}
return ("string" === typeof this.enc) ? this.enc.charCodeAt(pos) : this.enc[pos];
};
Stream.prototype.hexByte = function (b) {
return this.hexDigits.charAt((b >> 4) & 0xF) + this.hexDigits.charAt(b & 0xF);
};
Stream.prototype.hexDump = function (start, end, raw) {
var s = "";
for (var i = start; i < end; ++i) {
s += this.hexByte(this.get(i));
if (raw !== true) {
switch (i & 0xF) {
case 0x7:
s += " ";
break;
case 0xF:
s += "\n";
break;
default:
s += " ";
}
}
}
return s;
};
Stream.prototype.isASCII = function (start, end) {
for (var i = start; i < end; ++i) {
var c = this.get(i);
if (c < 32 || c > 176) {
return false;
}
}
return true;
};
Stream.prototype.parseStringISO = function (start, end) {
var s = "";
for (var i = start; i < end; ++i) {
s += String.fromCharCode(this.get(i));
}
return s;
};
Stream.prototype.parseStringUTF = function (start, end) {
var s = "";
for (var i = start; i < end;) {
var c = this.get(i++);
if (c < 128) {
s += String.fromCharCode(c);
}
else if ((c > 191) && (c < 224)) {
s += String.fromCharCode(((c & 0x1F) << 6) | (this.get(i++) & 0x3F));
}
else {
s += String.fromCharCode(((c & 0x0F) << 12) | ((this.get(i++) & 0x3F) << 6) | (this.get(i++) & 0x3F));
}
}
return s;
};
Stream.prototype.parseStringBMP = function (start, end) {
var str = "";
var hi;
var lo;
for (var i = start; i < end;) {
hi = this.get(i++);
lo = this.get(i++);
str += String.fromCharCode((hi << 8) | lo);
}
return str;
};
Stream.prototype.parseTime = function (start, end, shortYear) {
var s = this.parseStringISO(start, end);
var m = (shortYear ? reTimeS : reTimeL).exec(s);
if (!m) {
return "Unrecognized time: " + s;
}
if (shortYear) {
// to avoid querying the timer, use the fixed range [1970, 2069]
// it will conform with ITU X.400 [-10, +40] sliding window until 2030
m[1] = +m[1];
m[1] += (+m[1] < 70) ? 2000 : 1900;
}
s = m[1] + "-" + m[2] + "-" + m[3] + " " + m[4];
if (m[5]) {
s += ":" + m[5];
if (m[6]) {
s += ":" + m[6];
if (m[7]) {
s += "." + m[7];
}
}
}
if (m[8]) {
s += " UTC";
if (m[8] != "Z") {
s += m[8];
if (m[9]) {
s += ":" + m[9];
}
}
}
return s;
};
Stream.prototype.parseInteger = function (start, end) {
var v = this.get(start);
var neg = (v > 127);
var pad = neg ? 255 : 0;
var len;
var s = "";
// skip unuseful bits (not allowed in DER)
while (v == pad && ++start < end) {
v = this.get(start);
}
len = end - start;
if (len === 0) {
return neg ? -1 : 0;
}
// show bit length of huge integers
if (len > 4) {
s = v;
len <<= 3;
while (((+s ^ pad) & 0x80) == 0) {
s = +s << 1;
--len;
}
s = "(" + len + " bit)\n";
}
// decode the integer
if (neg) {
v = v - 256;
}
var n = new Int10(v);
for (var i = start + 1; i < end; ++i) {
n.mulAdd(256, this.get(i));
}
return s + n.toString();
};
Stream.prototype.parseBitString = function (start, end, maxLength) {
var unusedBit = this.get(start);
var lenBit = ((end - start - 1) << 3) - unusedBit;
var intro = "(" + lenBit + " bit)\n";
var s = "";
for (var i = start + 1; i < end; ++i) {
var b = this.get(i);
var skip = (i == end - 1) ? unusedBit : 0;
for (var j = 7; j >= skip; --j) {
s += (b >> j) & 1 ? "1" : "0";
}
if (s.length > maxLength) {
return intro + stringCut(s, maxLength);
}
}
return intro + s;
};
Stream.prototype.parseOctetString = function (start, end, maxLength) {
if (this.isASCII(start, end)) {
return stringCut(this.parseStringISO(start, end), maxLength);
}
var len = end - start;
var s = "(" + len + " byte)\n";
maxLength /= 2; // we work in bytes
if (len > maxLength) {
end = start + maxLength;
}
for (var i = start; i < end; ++i) {
s += this.hexByte(this.get(i));
}
if (len > maxLength) {
s += ellipsis;
}
return s;
};
Stream.prototype.parseOID = function (start, end, maxLength) {
var s = "";
var n = new Int10();
var bits = 0;
for (var i = start; i < end; ++i) {
var v = this.get(i);
n.mulAdd(128, v & 0x7F);
bits += 7;
if (!(v & 0x80)) { // finished
if (s === "") {
n = n.simplify();
if (n instanceof Int10) {
n.sub(80);
s = "2." + n.toString();
}
else {
var m = n < 80 ? n < 40 ? 0 : 1 : 2;
s = m + "." + (n - m * 40);
}
}
else {
s += "." + n.toString();
}
if (s.length > maxLength) {
return stringCut(s, maxLength);
}
n = new Int10();
bits = 0;
}
}
if (bits > 0) {
s += ".incomplete";
}
return s;
};
return Stream;
}());
export { Stream };
var ASN1 = /** @class */ (function () {
function ASN1(stream, header, length, tag, sub) {
if (!(tag instanceof ASN1Tag)) {
throw new Error("Invalid tag value.");
}
this.stream = stream;
this.header = header;
this.length = length;
this.tag = tag;
this.sub = sub;
}
ASN1.prototype.typeName = function () {
switch (this.tag.tagClass) {
case 0: // universal
switch (this.tag.tagNumber) {
case 0x00:
return "EOC";
case 0x01:
return "BOOLEAN";
case 0x02:
return "INTEGER";
case 0x03:
return "BIT_STRING";
case 0x04:
return "OCTET_STRING";
case 0x05:
return "NULL";
case 0x06:
return "OBJECT_IDENTIFIER";
case 0x07:
return "ObjectDescriptor";
case 0x08:
return "EXTERNAL";
case 0x09:
return "REAL";
case 0x0A:
return "ENUMERATED";
case 0x0B:
return "EMBEDDED_PDV";
case 0x0C:
return "UTF8String";
case 0x10:
return "SEQUENCE";
case 0x11:
return "SET";
case 0x12:
return "NumericString";
case 0x13:
return "PrintableString"; // ASCII subset
case 0x14:
return "TeletexString"; // aka T61String
case 0x15:
return "VideotexString";
case 0x16:
return "IA5String"; // ASCII
case 0x17:
return "UTCTime";
case 0x18:
return "GeneralizedTime";
case 0x19:
return "GraphicString";
case 0x1A:
return "VisibleString"; // ASCII subset
case 0x1B:
return "GeneralString";
case 0x1C:
return "UniversalString";
case 0x1E:
return "BMPString";
}
return "Universal_" + this.tag.tagNumber.toString();
case 1:
return "Application_" + this.tag.tagNumber.toString();
case 2:
return "[" + this.tag.tagNumber.toString() + "]"; // Context
case 3:
return "Private_" + this.tag.tagNumber.toString();
}
};
ASN1.prototype.content = function (maxLength) {
if (this.tag === undefined) {
return null;
}
if (maxLength === undefined) {
maxLength = Infinity;
}
var content = this.posContent();
var len = Math.abs(this.length);
if (!this.tag.isUniversal()) {
if (this.sub !== null) {
return "(" + this.sub.length + " elem)";
}
return this.stream.parseOctetString(content, content + len, maxLength);
}
switch (this.tag.tagNumber) {
case 0x01: // BOOLEAN
return (this.stream.get(content) === 0) ? "false" : "true";
case 0x02: // INTEGER
return this.stream.parseInteger(content, content + len);
case 0x03: // BIT_STRING
return this.sub ? "(" + this.sub.length + " elem)" :
this.stream.parseBitString(content, content + len, maxLength);
case 0x04: // OCTET_STRING
return this.sub ? "(" + this.sub.length + " elem)" :
this.stream.parseOctetString(content, content + len, maxLength);
// case 0x05: // NULL
case 0x06: // OBJECT_IDENTIFIER
return this.stream.parseOID(content, content + len, maxLength);
// case 0x07: // ObjectDescriptor
// case 0x08: // EXTERNAL
// case 0x09: // REAL
// case 0x0A: // ENUMERATED
// case 0x0B: // EMBEDDED_PDV
case 0x10: // SEQUENCE
case 0x11: // SET
if (this.sub !== null) {
return "(" + this.sub.length + " elem)";
}
else {
return "(no elem)";
}
case 0x0C: // UTF8String
return stringCut(this.stream.parseStringUTF(content, content + len), maxLength);
case 0x12: // NumericString
case 0x13: // PrintableString
case 0x14: // TeletexString
case 0x15: // VideotexString
case 0x16: // IA5String
// case 0x19: // GraphicString
case 0x1A: // VisibleString
// case 0x1B: // GeneralString
// case 0x1C: // UniversalString
return stringCut(this.stream.parseStringISO(content, content + len), maxLength);
case 0x1E: // BMPString
return stringCut(this.stream.parseStringBMP(content, content + len), maxLength);
case 0x17: // UTCTime
case 0x18: // GeneralizedTime
return this.stream.parseTime(content, content + len, (this.tag.tagNumber == 0x17));
}
return null;
};
ASN1.prototype.toString = function () {
return this.typeName() + "@" + this.stream.pos + "[header:" + this.header + ",length:" + this.length + ",sub:" + ((this.sub === null) ? "null" : this.sub.length) + "]";
};
ASN1.prototype.toPrettyString = function (indent) {
if (indent === undefined) {
indent = "";
}
var s = indent + this.typeName() + " @" + this.stream.pos;
if (this.length >= 0) {
s += "+";
}
s += this.length;
if (this.tag.tagConstructed) {
s += " (constructed)";
}
else if ((this.tag.isUniversal() && ((this.tag.tagNumber == 0x03) || (this.tag.tagNumber == 0x04))) && (this.sub !== null)) {
s += " (encapsulates)";
}
s += "\n";
if (this.sub !== null) {
indent += " ";
for (var i = 0, max = this.sub.length; i < max; ++i) {
s += this.sub[i].toPrettyString(indent);
}
}
return s;
};
ASN1.prototype.posStart = function () {
return this.stream.pos;
};
ASN1.prototype.posContent = function () {
return this.stream.pos + this.header;
};
ASN1.prototype.posEnd = function () {
return this.stream.pos + this.header + Math.abs(this.length);
};
ASN1.prototype.toHexString = function () {
return this.stream.hexDump(this.posStart(), this.posEnd(), true);
};
ASN1.decodeLength = function (stream) {
var buf = stream.get();
var len = buf & 0x7F;
if (len == buf) {
return len;
}
// no reason to use Int10, as it would be a huge buffer anyways
if (len > 6) {
throw new Error("Length over 48 bits not supported at position " + (stream.pos - 1));
}
if (len === 0) {
return null;
} // undefined
buf = 0;
for (var i = 0; i < len; ++i) {
buf = (buf * 256) + stream.get();
}
return buf;
};
/**
* Retrieve the hexadecimal value (as a string) of the current ASN.1 element
* @returns {string}
* @public
*/
ASN1.prototype.getHexStringValue = function () {
var hexString = this.toHexString();
var offset = this.header * 2;
var length = this.length * 2;
return hexString.substr(offset, length);
};
ASN1.decode = function (str) {
var stream;
if (!(str instanceof Stream)) {
stream = new Stream(str, 0);
}
else {
stream = str;
}
var streamStart = new Stream(stream);
var tag = new ASN1Tag(stream);
var len = ASN1.decodeLength(stream);
var start = stream.pos;
var header = start - streamStart.pos;
var sub = null;
var getSub = function () {
var ret = [];
if (len !== null) {
// definite length
var end = start + len;
while (stream.pos < end) {
ret[ret.length] = ASN1.decode(stream);
}
if (stream.pos != end) {
throw new Error("Content size is not correct for container starting at offset " + start);
}
}
else {
// undefined length
try {
for (;;) {
var s = ASN1.decode(stream);
if (s.tag.isEOC()) {
break;
}
ret[ret.length] = s;
}
len = start - stream.pos; // undefined lengths are represented as negative values
}
catch (e) {
throw new Error("Exception while decoding undefined length content: " + e);
}
}
return ret;
};
if (tag.tagConstructed) {
// must have valid content
sub = getSub();
}
else if (tag.isUniversal() && ((tag.tagNumber == 0x03) || (tag.tagNumber == 0x04))) {
// sometimes BitString and OctetString are used to encapsulate ASN.1
try {
if (tag.tagNumber == 0x03) {
if (stream.get() != 0) {
throw new Error("BIT STRINGs with unused bits cannot encapsulate.");
}
}
sub = getSub();
for (var i = 0; i < sub.length; ++i) {
if (sub[i].tag.isEOC()) {
throw new Error("EOC is not supposed to be actual content.");
}
}
}
catch (e) {
// but silently ignore when they don't
sub = null;
}
}
if (sub === null) {
if (len === null) {
throw new Error("We can't skip over an invalid tag with undefined length at offset " + start);
}
stream.pos = start + Math.abs(len);
}
return new ASN1(streamStart, header, len, tag, sub);
};
return ASN1;
}());
export { ASN1 };
var ASN1Tag = /** @class */ (function () {
function ASN1Tag(stream) {
var buf = stream.get();
this.tagClass = buf >> 6;
this.tagConstructed = ((buf & 0x20) !== 0);
this.tagNumber = buf & 0x1F;
if (this.tagNumber == 0x1F) { // long tag
var n = new Int10();
do {
buf = stream.get();
n.mulAdd(128, buf & 0x7F);
} while (buf & 0x80);
this.tagNumber = n.simplify();
}
}
ASN1Tag.prototype.isUniversal = function () {
return this.tagClass === 0x00;
};
ASN1Tag.prototype.isEOC = function () {
return this.tagClass === 0x00 && this.tagNumber === 0x00;
};
return ASN1Tag;
}());
export { ASN1Tag };

5
libs/jsencrypt/lib/lib/asn1js/base64.d.ts

@ -0,0 +1,5 @@
export declare const Base64: {
decode(a: string): number[];
re: RegExp;
unarmor(a: string): number[];
};

88
libs/jsencrypt/lib/lib/asn1js/base64.js

@ -0,0 +1,88 @@
// Base64 JavaScript decoder
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
var decoder;
export var Base64 = {
decode: function (a) {
var i;
if (decoder === undefined) {
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var ignore = "= \f\n\r\t\u00A0\u2028\u2029";
decoder = Object.create(null);
for (i = 0; i < 64; ++i) {
decoder[b64.charAt(i)] = i;
}
decoder['-'] = 62; //+
decoder['_'] = 63; //-
for (i = 0; i < ignore.length; ++i) {
decoder[ignore.charAt(i)] = -1;
}
}
var out = [];
var bits = 0;
var char_count = 0;
for (i = 0; i < a.length; ++i) {
var c = a.charAt(i);
if (c == "=") {
break;
}
c = decoder[c];
if (c == -1) {
continue;
}
if (c === undefined) {
throw new Error("Illegal character at offset " + i);
}
bits |= c;
if (++char_count >= 4) {
out[out.length] = (bits >> 16);
out[out.length] = (bits >> 8) & 0xFF;
out[out.length] = bits & 0xFF;
bits = 0;
char_count = 0;
}
else {
bits <<= 6;
}
}
switch (char_count) {
case 1:
throw new Error("Base64 encoding incomplete: at least 2 bits missing");
case 2:
out[out.length] = (bits >> 10);
break;
case 3:
out[out.length] = (bits >> 16);
out[out.length] = (bits >> 8) & 0xFF;
break;
}
return out;
},
re: /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,
unarmor: function (a) {
var m = Base64.re.exec(a);
if (m) {
if (m[1]) {
a = m[1];
}
else if (m[2]) {
a = m[2];
}
else {
throw new Error("RegExp out of sync");
}
}
return Base64.decode(a);
}
};

3
libs/jsencrypt/lib/lib/asn1js/hex.d.ts

@ -0,0 +1,3 @@
export declare const Hex: {
decode(a: string): number[];
};

64
libs/jsencrypt/lib/lib/asn1js/hex.js

@ -0,0 +1,64 @@
// Hex JavaScript decoder
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
var decoder;
export var Hex = {
decode: function (a) {
var i;
if (decoder === undefined) {
var hex = "0123456789ABCDEF";
var ignore = " \f\n\r\t\u00A0\u2028\u2029";
decoder = {};
for (i = 0; i < 16; ++i) {
decoder[hex.charAt(i)] = i;
}
hex = hex.toLowerCase();
for (i = 10; i < 16; ++i) {
decoder[hex.charAt(i)] = i;
}
for (i = 0; i < ignore.length; ++i) {
decoder[ignore.charAt(i)] = -1;
}
}
var out = [];
var bits = 0;
var char_count = 0;
for (i = 0; i < a.length; ++i) {
var c = a.charAt(i);
if (c == "=") {
break;
}
c = decoder[c];
if (c == -1) {
continue;
}
if (c === undefined) {
throw new Error("Illegal character at offset " + i);
}
bits |= c;
if (++char_count >= 2) {
out[out.length] = bits;
bits = 0;
char_count = 0;
}
else {
bits <<= 4;
}
}
if (char_count) {
throw new Error("Hex encoding incomplete: 4 bits missing");
}
return out;
}
};

9
libs/jsencrypt/lib/lib/asn1js/int10.d.ts

@ -0,0 +1,9 @@
export declare class Int10 {
constructor(value?: string | number);
mulAdd(m: number, c: number): void;
sub(c: number): void;
toString(base?: number): string;
valueOf(): number;
simplify(): number | this;
private buf;
}

87
libs/jsencrypt/lib/lib/asn1js/int10.js

@ -0,0 +1,87 @@
// Big integer base-10 printing library
// Copyright (c) 2014 Lapo Luchini <lapo@lapo.it>
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/*jshint browser: true, strict: true, immed: true, latedef: true, undef: true, regexdash: false */
var max = 10000000000000; // biggest integer that can still fit 2^53 when multiplied by 256
var Int10 = /** @class */ (function () {
function Int10(value) {
this.buf = [+value || 0];
}
Int10.prototype.mulAdd = function (m, c) {
// assert(m <= 256)
var b = this.buf;
var l = b.length;
var i;
var t;
for (i = 0; i < l; ++i) {
t = b[i] * m + c;
if (t < max) {
c = 0;
}
else {
c = 0 | (t / max);
t -= c * max;
}
b[i] = t;
}
if (c > 0) {
b[i] = c;
}
};
Int10.prototype.sub = function (c) {
// assert(m <= 256)
var b = this.buf;
var l = b.length;
var i;
var t;
for (i = 0; i < l; ++i) {
t = b[i] - c;
if (t < 0) {
t += max;
c = 1;
}
else {
c = 0;
}
b[i] = t;
}
while (b[b.length - 1] === 0) {
b.pop();
}
};
Int10.prototype.toString = function (base) {
if ((base || 10) != 10) {
throw new Error("only base 10 is supported");
}
var b = this.buf;
var s = b[b.length - 1].toString();
for (var i = b.length - 2; i >= 0; --i) {
s += (max + b[i]).toString().substring(1);
}
return s;
};
Int10.prototype.valueOf = function () {
var b = this.buf;
var v = 0;
for (var i = b.length - 1; i >= 0; --i) {
v = v * max + b[i];
}
return v;
};
Int10.prototype.simplify = function () {
var b = this.buf;
return (b.length == 1) ? b[0] : this;
};
return Int10;
}());
export { Int10 };

9778
libs/jsencrypt/lib/lib/asn1js/oids.d.ts

File diff suppressed because it is too large

1962
libs/jsencrypt/lib/lib/asn1js/oids.js

File diff suppressed because it is too large

3
libs/jsencrypt/lib/lib/jsbn/base64.d.ts

@ -0,0 +1,3 @@
export declare function hex2b64(h: string): string;
export declare function b64tohex(s: string): string;
export declare function b64toBA(s: string): number[];

76
libs/jsencrypt/lib/lib/jsbn/base64.js

@ -0,0 +1,76 @@
import { int2char } from "./util";
var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var b64pad = "=";
export function hex2b64(h) {
var i;
var c;
var ret = "";
for (i = 0; i + 3 <= h.length; i += 3) {
c = parseInt(h.substring(i, i + 3), 16);
ret += b64map.charAt(c >> 6) + b64map.charAt(c & 63);
}
if (i + 1 == h.length) {
c = parseInt(h.substring(i, i + 1), 16);
ret += b64map.charAt(c << 2);
}
else if (i + 2 == h.length) {
c = parseInt(h.substring(i, i + 2), 16);
ret += b64map.charAt(c >> 2) + b64map.charAt((c & 3) << 4);
}
while ((ret.length & 3) > 0) {
ret += b64pad;
}
return ret;
}
// convert a base64 string to hex
export function b64tohex(s) {
var ret = "";
var i;
var k = 0; // b64 state, 0-3
var slop = 0;
for (i = 0; i < s.length; ++i) {
if (s.charAt(i) == b64pad) {
break;
}
var v = b64map.indexOf(s.charAt(i));
if (v < 0) {
continue;
}
if (k == 0) {
ret += int2char(v >> 2);
slop = v & 3;
k = 1;
}
else if (k == 1) {
ret += int2char((slop << 2) | (v >> 4));
slop = v & 0xf;
k = 2;
}
else if (k == 2) {
ret += int2char(slop);
ret += int2char(v >> 2);
slop = v & 3;
k = 3;
}
else {
ret += int2char((slop << 2) | (v >> 4));
ret += int2char(v & 0xf);
k = 0;
}
}
if (k == 1) {
ret += int2char(slop << 2);
}
return ret;
}
// convert a base64 string to a byte/number array
export function b64toBA(s) {
// piggyback on b64tohex for now, optimize later
var h = b64tohex(s);
var i;
var a = [];
for (i = 0; 2 * i < h.length; ++i) {
a[i] = parseInt(h.substring(2 * i, 2 * i + 2), 16);
}
return a;
}

98
libs/jsencrypt/lib/lib/jsbn/jsbn.d.ts

@ -0,0 +1,98 @@
import { SecureRandom } from "./rng";
export declare class BigInteger {
constructor(a: number | number[] | string, b?: number | SecureRandom, c?: number | SecureRandom);
toString(b: number): string;
protected negate(): BigInteger;
abs(): BigInteger;
compareTo(a: BigInteger): number;
bitLength(): number;
mod(a: BigInteger): BigInteger;
modPowInt(e: number, m: BigInteger): BigInteger;
protected clone(): BigInteger;
protected intValue(): number;
protected byteValue(): number;
protected shortValue(): number;
protected signum(): 0 | 1 | -1;
toByteArray(): number[];
protected equals(a: BigInteger): boolean;
protected min(a: BigInteger): BigInteger;
protected max(a: BigInteger): BigInteger;
protected and(a: BigInteger): BigInteger;
protected or(a: BigInteger): BigInteger;
protected xor(a: BigInteger): BigInteger;
protected andNot(a: BigInteger): BigInteger;
protected not(): BigInteger;
protected shiftLeft(n: number): BigInteger;
protected shiftRight(n: number): BigInteger;
protected getLowestSetBit(): number;
protected bitCount(): number;
protected testBit(n: number): boolean;
protected setBit(n: number): BigInteger;
protected clearBit(n: number): BigInteger;
protected flipBit(n: number): BigInteger;
add(a: BigInteger): BigInteger;
subtract(a: BigInteger): BigInteger;
multiply(a: BigInteger): BigInteger;
divide(a: BigInteger): BigInteger;
protected remainder(a: BigInteger): BigInteger;
protected divideAndRemainder(a: BigInteger): BigInteger[];
modPow(e: BigInteger, m: BigInteger): BigInteger;
modInverse(m: BigInteger): BigInteger;
protected pow(e: number): BigInteger;
gcd(a: BigInteger): BigInteger;
isProbablePrime(t: number): boolean;
copyTo(r: BigInteger): void;
fromInt(x: number): void;
protected fromString(s: string | number[], b: number): void;
clamp(): void;
dlShiftTo(n: number, r: BigInteger): void;
drShiftTo(n: number, r: BigInteger): void;
protected lShiftTo(n: number, r: BigInteger): void;
protected rShiftTo(n: number, r: BigInteger): void;
subTo(a: BigInteger, r: BigInteger): void;
multiplyTo(a: BigInteger, r: BigInteger): void;
squareTo(r: BigInteger): void;
divRemTo(m: BigInteger, q: BigInteger, r: BigInteger): void;
invDigit(): number;
protected isEven(): boolean;
protected exp(e: number, z: IReduction): BigInteger;
protected chunkSize(r: number): number;
protected toRadix(b: number): string;
fromRadix(s: string, b: number): void;
protected fromNumber(a: number, b: number | SecureRandom, c?: number | SecureRandom): void;
protected bitwiseTo(a: BigInteger, op: (a: number, b: number) => number, r: BigInteger): void;
protected changeBit(n: number, op: (a: number, b: number) => number): BigInteger;
protected addTo(a: BigInteger, r: BigInteger): void;
protected dMultiply(n: number): void;
dAddOffset(n: number, w: number): void;
multiplyLowerTo(a: BigInteger, n: number, r: BigInteger): void;
multiplyUpperTo(a: BigInteger, n: number, r: BigInteger): void;
protected modInt(n: number): number;
protected millerRabin(t: number): boolean;
protected square(): BigInteger;
gcda(a: BigInteger, callback: (x: BigInteger) => void): void;
fromNumberAsync(a: number, b: number | SecureRandom, c: number | SecureRandom, callback: () => void): void;
s: number;
t: number;
DB: number;
DM: number;
DV: number;
FV: number;
F1: number;
F2: number;
am: (i: number, x: number, w: BigInteger, j: number, c: number, n: number) => number;
[index: number]: number;
static ONE: BigInteger;
static ZERO: BigInteger;
}
export interface IReduction {
convert(x: BigInteger): BigInteger;
revert(x: BigInteger): BigInteger;
mulTo(x: BigInteger, y: BigInteger, r: BigInteger): void;
sqrTo(x: BigInteger, r: BigInteger): void;
}
export declare function nbi(): BigInteger;
export declare function parseBigInt(str: string, r: number): BigInteger;
export declare function intAt(s: string, i: number): number;
export declare function nbv(i: number): BigInteger;
export declare function nbits(x: number): number;

1754
libs/jsencrypt/lib/lib/jsbn/jsbn.js

File diff suppressed because it is too large

10
libs/jsencrypt/lib/lib/jsbn/prng4.d.ts

@ -0,0 +1,10 @@
export declare class Arcfour {
constructor();
init(key: number[]): void;
next(): number;
private i;
private j;
private S;
}
export declare function prng_newstate(): Arcfour;
export declare let rng_psize: number;

46
libs/jsencrypt/lib/lib/jsbn/prng4.js

@ -0,0 +1,46 @@
// prng4.js - uses Arcfour as a PRNG
var Arcfour = /** @class */ (function () {
function Arcfour() {
this.i = 0;
this.j = 0;
this.S = [];
}
// Arcfour.prototype.init = ARC4init;
// Initialize arcfour context from key, an array of ints, each from [0..255]
Arcfour.prototype.init = function (key) {
var i;
var j;
var t;
for (i = 0; i < 256; ++i) {
this.S[i] = i;
}
j = 0;
for (i = 0; i < 256; ++i) {
j = (j + this.S[i] + key[i % key.length]) & 255;
t = this.S[i];
this.S[i] = this.S[j];
this.S[j] = t;
}
this.i = 0;
this.j = 0;
};
// Arcfour.prototype.next = ARC4next;
Arcfour.prototype.next = function () {
var t;
this.i = (this.i + 1) & 255;
this.j = (this.j + this.S[this.i]) & 255;
t = this.S[this.i];
this.S[this.i] = this.S[this.j];
this.S[this.j] = t;
return this.S[(t + this.S[this.i]) & 255];
};
return Arcfour;
}());
export { Arcfour };
// Plug in your RNG constructor here
export function prng_newstate() {
return new Arcfour();
}
// Pool size must be a multiple of 4 and greater than 32.
// An array of bytes the size of the pool will be passed to init()
export var rng_psize = 256;

3
libs/jsencrypt/lib/lib/jsbn/rng.d.ts

@ -0,0 +1,3 @@
export declare class SecureRandom {
nextBytes(ba: number[]): void;
}

78
libs/jsencrypt/lib/lib/jsbn/rng.js

@ -0,0 +1,78 @@
// Random number generator - requires a PRNG backend, e.g. prng4.js
import { prng_newstate, rng_psize } from "./prng4";
var rng_state;
var rng_pool = null;
var rng_pptr;
// Initialize the pool with junk if needed.
if (rng_pool == null) {
rng_pool = [];
rng_pptr = 0;
var t = void 0;
if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
// Extract entropy (2048 bits) from RNG if available
var z = new Uint32Array(256);
window.crypto.getRandomValues(z);
for (t = 0; t < z.length; ++t) {
rng_pool[rng_pptr++] = z[t] & 255;
}
}
// Use mouse events for entropy, if we do not have enough entropy by the time
// we need it, entropy will be generated by Math.random.
var count = 0;
var onMouseMoveListener_1 = function (ev) {
count = count || 0;
if (count >= 256 || rng_pptr >= rng_psize) {
if (window.removeEventListener) {
window.removeEventListener("mousemove", onMouseMoveListener_1, false);
}
else if (window.detachEvent) {
window.detachEvent("onmousemove", onMouseMoveListener_1);
}
return;
}
try {
var mouseCoordinates = ev.x + ev.y;
rng_pool[rng_pptr++] = mouseCoordinates & 255;
count += 1;
}
catch (e) {
// Sometimes Firefox will deny permission to access event properties for some reason. Ignore.
}
};
if (typeof window !== 'undefined') {
if (window.addEventListener) {
window.addEventListener("mousemove", onMouseMoveListener_1, false);
}
else if (window.attachEvent) {
window.attachEvent("onmousemove", onMouseMoveListener_1);
}
}
}
function rng_get_byte() {
if (rng_state == null) {
rng_state = prng_newstate();
// At this point, we may not have collected enough entropy. If not, fall back to Math.random
while (rng_pptr < rng_psize) {
var random = Math.floor(65536 * Math.random());
rng_pool[rng_pptr++] = random & 255;
}
rng_state.init(rng_pool);
for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) {
rng_pool[rng_pptr] = 0;
}
rng_pptr = 0;
}
// TODO: allow reseeding after first request
return rng_state.next();
}
var SecureRandom = /** @class */ (function () {
function SecureRandom() {
}
SecureRandom.prototype.nextBytes = function (ba) {
for (var i = 0; i < ba.length; ++i) {
ba[i] = rng_get_byte();
}
};
return SecureRandom;
}());
export { SecureRandom };

23
libs/jsencrypt/lib/lib/jsbn/rsa.d.ts

@ -0,0 +1,23 @@
import { BigInteger } from "./jsbn";
export declare class RSAKey {
constructor();
doPublic(x: BigInteger): BigInteger;
doPrivate(x: BigInteger): BigInteger;
setPublic(N: string, E: string): void;
encrypt(text: string): string;
setPrivate(N: string, E: string, D: string): void;
setPrivateEx(N: string, E: string, D: string, P: string, Q: string, DP: string, DQ: string, C: string): void;
generate(B: number, E: string): void;
decrypt(ctext: string): string;
generateAsync(B: number, E: string, callback: () => void): void;
sign(text: string, digestMethod: (str: string) => string, digestName: string): string;
verify(text: string, signature: string, digestMethod: (str: string) => string): boolean;
protected n: BigInteger;
protected e: number;
protected d: BigInteger;
protected p: BigInteger;
protected q: BigInteger;
protected dmp1: BigInteger;
protected dmq1: BigInteger;
protected coeff: BigInteger;
}

373
libs/jsencrypt/lib/lib/jsbn/rsa.js

@ -0,0 +1,373 @@
// Depends on jsbn.js and rng.js
// Version 1.1: support utf-8 encoding in pkcs1pad2
// convert a (hex) string to a bignum object
import { BigInteger, nbi, parseBigInt } from "./jsbn";
import { SecureRandom } from "./rng";
// function linebrk(s,n) {
// var ret = "";
// var i = 0;
// while(i + n < s.length) {
// ret += s.substring(i,i+n) + "\n";
// i += n;
// }
// return ret + s.substring(i,s.length);
// }
// function byte2Hex(b) {
// if(b < 0x10)
// return "0" + b.toString(16);
// else
// return b.toString(16);
// }
function pkcs1pad1(s, n) {
if (n < s.length + 22) {
console.error("Message too long for RSA");
return null;
}
var len = n - s.length - 6;
var filler = "";
for (var f = 0; f < len; f += 2) {
filler += "ff";
}
var m = "0001" + filler + "00" + s;
return parseBigInt(m, 16);
}
// PKCS#1 (type 2, random) pad input string s to n bytes, and return a bigint
function pkcs1pad2(s, n) {
if (n < s.length + 11) { // TODO: fix for utf-8
console.error("Message too long for RSA");
return null;
}
var ba = [];
var i = s.length - 1;
while (i >= 0 && n > 0) {
var c = s.charCodeAt(i--);
if (c < 128) { // encode using utf-8
ba[--n] = c;
}
else if ((c > 127) && (c < 2048)) {
ba[--n] = (c & 63) | 128;
ba[--n] = (c >> 6) | 192;
}
else {
ba[--n] = (c & 63) | 128;
ba[--n] = ((c >> 6) & 63) | 128;
ba[--n] = (c >> 12) | 224;
}
}
ba[--n] = 0;
var rng = new SecureRandom();
var x = [];
while (n > 2) { // random non-zero pad
x[0] = 0;
while (x[0] == 0) {
rng.nextBytes(x);
}
ba[--n] = x[0];
}
ba[--n] = 2;
ba[--n] = 0;
return new BigInteger(ba);
}
// "empty" RSA key constructor
var RSAKey = /** @class */ (function () {
function RSAKey() {
this.n = null;
this.e = 0;
this.d = null;
this.p = null;
this.q = null;
this.dmp1 = null;
this.dmq1 = null;
this.coeff = null;
}
//#region PROTECTED
// protected
// RSAKey.prototype.doPublic = RSADoPublic;
// Perform raw public operation on "x": return x^e (mod n)
RSAKey.prototype.doPublic = function (x) {
return x.modPowInt(this.e, this.n);
};
// RSAKey.prototype.doPrivate = RSADoPrivate;
// Perform raw private operation on "x": return x^d (mod n)
RSAKey.prototype.doPrivate = function (x) {
if (this.p == null || this.q == null) {
return x.modPow(this.d, this.n);
}
// TODO: re-calculate any missing CRT params
var xp = x.mod(this.p).modPow(this.dmp1, this.p);
var xq = x.mod(this.q).modPow(this.dmq1, this.q);
while (xp.compareTo(xq) < 0) {
xp = xp.add(this.p);
}
return xp.subtract(xq).multiply(this.coeff).mod(this.p).multiply(this.q).add(xq);
};
//#endregion PROTECTED
//#region PUBLIC
// RSAKey.prototype.setPublic = RSASetPublic;
// Set the public key fields N and e from hex strings
RSAKey.prototype.setPublic = function (N, E) {
if (N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N, 16);
this.e = parseInt(E, 16);
}
else {
console.error("Invalid RSA public key");
}
};
// RSAKey.prototype.encrypt = RSAEncrypt;
// Return the PKCS#1 RSA encryption of "text" as an even-length hex string
RSAKey.prototype.encrypt = function (text) {
var maxLength = (this.n.bitLength() + 7) >> 3;
var m = pkcs1pad2(text, maxLength);
if (m == null) {
return null;
}
var c = this.doPublic(m);
if (c == null) {
return null;
}
var h = c.toString(16);
var length = h.length;
// fix zero before result
for (var i = 0; i < maxLength * 2 - length; i++) {
h = "0" + h;
}
return h;
};
// RSAKey.prototype.setPrivate = RSASetPrivate;
// Set the private key fields N, e, and d from hex strings
RSAKey.prototype.setPrivate = function (N, E, D) {
if (N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N, 16);
this.e = parseInt(E, 16);
this.d = parseBigInt(D, 16);
}
else {
console.error("Invalid RSA private key");
}
};
// RSAKey.prototype.setPrivateEx = RSASetPrivateEx;
// Set the private key fields N, e, d and CRT params from hex strings
RSAKey.prototype.setPrivateEx = function (N, E, D, P, Q, DP, DQ, C) {
if (N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N, 16);
this.e = parseInt(E, 16);
this.d = parseBigInt(D, 16);
this.p = parseBigInt(P, 16);
this.q = parseBigInt(Q, 16);
this.dmp1 = parseBigInt(DP, 16);
this.dmq1 = parseBigInt(DQ, 16);
this.coeff = parseBigInt(C, 16);
}
else {
console.error("Invalid RSA private key");
}
};
// RSAKey.prototype.generate = RSAGenerate;
// Generate a new random private key B bits long, using public expt E
RSAKey.prototype.generate = function (B, E) {
var rng = new SecureRandom();
var qs = B >> 1;
this.e = parseInt(E, 16);
var ee = new BigInteger(E, 16);
for (;;) {
for (;;) {
this.p = new BigInteger(B - qs, 1, rng);
if (this.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.p.isProbablePrime(10)) {
break;
}
}
for (;;) {
this.q = new BigInteger(qs, 1, rng);
if (this.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE) == 0 && this.q.isProbablePrime(10)) {
break;
}
}
if (this.p.compareTo(this.q) <= 0) {
var t = this.p;
this.p = this.q;
this.q = t;
}
var p1 = this.p.subtract(BigInteger.ONE);
var q1 = this.q.subtract(BigInteger.ONE);
var phi = p1.multiply(q1);
if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
this.n = this.p.multiply(this.q);
this.d = ee.modInverse(phi);
this.dmp1 = this.d.mod(p1);
this.dmq1 = this.d.mod(q1);
this.coeff = this.q.modInverse(this.p);
break;
}
}
};
// RSAKey.prototype.decrypt = RSADecrypt;
// Return the PKCS#1 RSA decryption of "ctext".
// "ctext" is an even-length hex string and the output is a plain string.
RSAKey.prototype.decrypt = function (ctext) {
var c = parseBigInt(ctext, 16);
var m = this.doPrivate(c);
if (m == null) {
return null;
}
return pkcs1unpad2(m, (this.n.bitLength() + 7) >> 3);
};
// Generate a new random private key B bits long, using public expt E
RSAKey.prototype.generateAsync = function (B, E, callback) {
var rng = new SecureRandom();
var qs = B >> 1;
this.e = parseInt(E, 16);
var ee = new BigInteger(E, 16);
var rsa = this;
// These functions have non-descript names because they were originally for(;;) loops.
// I don't know about cryptography to give them better names than loop1-4.
var loop1 = function () {
var loop4 = function () {
if (rsa.p.compareTo(rsa.q) <= 0) {
var t = rsa.p;
rsa.p = rsa.q;
rsa.q = t;
}
var p1 = rsa.p.subtract(BigInteger.ONE);
var q1 = rsa.q.subtract(BigInteger.ONE);
var phi = p1.multiply(q1);
if (phi.gcd(ee).compareTo(BigInteger.ONE) == 0) {
rsa.n = rsa.p.multiply(rsa.q);
rsa.d = ee.modInverse(phi);
rsa.dmp1 = rsa.d.mod(p1);
rsa.dmq1 = rsa.d.mod(q1);
rsa.coeff = rsa.q.modInverse(rsa.p);
setTimeout(function () { callback(); }, 0); // escape
}
else {
setTimeout(loop1, 0);
}
};
var loop3 = function () {
rsa.q = nbi();
rsa.q.fromNumberAsync(qs, 1, rng, function () {
rsa.q.subtract(BigInteger.ONE).gcda(ee, function (r) {
if (r.compareTo(BigInteger.ONE) == 0 && rsa.q.isProbablePrime(10)) {
setTimeout(loop4, 0);
}
else {
setTimeout(loop3, 0);
}
});
});
};
var loop2 = function () {
rsa.p = nbi();
rsa.p.fromNumberAsync(B - qs, 1, rng, function () {
rsa.p.subtract(BigInteger.ONE).gcda(ee, function (r) {
if (r.compareTo(BigInteger.ONE) == 0 && rsa.p.isProbablePrime(10)) {
setTimeout(loop3, 0);
}
else {
setTimeout(loop2, 0);
}
});
});
};
setTimeout(loop2, 0);
};
setTimeout(loop1, 0);
};
RSAKey.prototype.sign = function (text, digestMethod, digestName) {
var header = getDigestHeader(digestName);
var digest = header + digestMethod(text).toString();
var m = pkcs1pad1(digest, this.n.bitLength() / 4);
if (m == null) {
return null;
}
var c = this.doPrivate(m);
if (c == null) {
return null;
}
var h = c.toString(16);
if ((h.length & 1) == 0) {
return h;
}
else {
return "0" + h;
}
};
RSAKey.prototype.verify = function (text, signature, digestMethod) {
var c = parseBigInt(signature, 16);
var m = this.doPublic(c);
if (m == null) {
return null;
}
var unpadded = m.toString(16).replace(/^1f+00/, "");
var digest = removeDigestHeader(unpadded);
return digest == digestMethod(text).toString();
};
return RSAKey;
}());
export { RSAKey };
// Undo PKCS#1 (type 2, random) padding and, if valid, return the plaintext
function pkcs1unpad2(d, n) {
var b = d.toByteArray();
var i = 0;
while (i < b.length && b[i] == 0) {
++i;
}
if (b.length - i != n - 1 || b[i] != 2) {
return null;
}
++i;
while (b[i] != 0) {
if (++i >= b.length) {
return null;
}
}
var ret = "";
while (++i < b.length) {
var c = b[i] & 255;
if (c < 128) { // utf-8 decode
ret += String.fromCharCode(c);
}
else if ((c > 191) && (c < 224)) {
ret += String.fromCharCode(((c & 31) << 6) | (b[i + 1] & 63));
++i;
}
else {
ret += String.fromCharCode(((c & 15) << 12) | ((b[i + 1] & 63) << 6) | (b[i + 2] & 63));
i += 2;
}
}
return ret;
}
// https://tools.ietf.org/html/rfc3447#page-43
var DIGEST_HEADERS = {
md2: "3020300c06082a864886f70d020205000410",
md5: "3020300c06082a864886f70d020505000410",
sha1: "3021300906052b0e03021a05000414",
sha224: "302d300d06096086480165030402040500041c",
sha256: "3031300d060960864801650304020105000420",
sha384: "3041300d060960864801650304020205000430",
sha512: "3051300d060960864801650304020305000440",
ripemd160: "3021300906052b2403020105000414"
};
function getDigestHeader(name) {
return DIGEST_HEADERS[name] || "";
}
function removeDigestHeader(str) {
for (var name_1 in DIGEST_HEADERS) {
if (DIGEST_HEADERS.hasOwnProperty(name_1)) {
var header = DIGEST_HEADERS[name_1];
var len = header.length;
if (str.substr(0, len) == header) {
return str.substr(len);
}
}
}
return str;
}
// Return the PKCS#1 RSA encryption of "text" as a Base64-encoded string
// function RSAEncryptB64(text) {
// var h = this.encrypt(text);
// if(h) return hex2b64(h); else return null;
// }
// public
// RSAKey.prototype.encrypt_b64 = RSAEncryptB64;

7
libs/jsencrypt/lib/lib/jsbn/util.d.ts

@ -0,0 +1,7 @@
export declare function int2char(n: number): string;
export declare function op_and(x: number, y: number): number;
export declare function op_or(x: number, y: number): number;
export declare function op_xor(x: number, y: number): number;
export declare function op_andnot(x: number, y: number): number;
export declare function lbit(x: number): number;
export declare function cbit(x: number): number;

58
libs/jsencrypt/lib/lib/jsbn/util.js

@ -0,0 +1,58 @@
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
export function int2char(n) {
return BI_RM.charAt(n);
}
//#region BIT_OPERATIONS
// (public) this & a
export function op_and(x, y) {
return x & y;
}
// (public) this | a
export function op_or(x, y) {
return x | y;
}
// (public) this ^ a
export function op_xor(x, y) {
return x ^ y;
}
// (public) this & ~a
export function op_andnot(x, y) {
return x & ~y;
}
// return index of lowest 1-bit in x, x < 2^31
export function lbit(x) {
if (x == 0) {
return -1;
}
var r = 0;
if ((x & 0xffff) == 0) {
x >>= 16;
r += 16;
}
if ((x & 0xff) == 0) {
x >>= 8;
r += 8;
}
if ((x & 0xf) == 0) {
x >>= 4;
r += 4;
}
if ((x & 3) == 0) {
x >>= 2;
r += 2;
}
if ((x & 1) == 0) {
++r;
}
return r;
}
// return number of 1 bits in x
export function cbit(x) {
var r = 0;
while (x != 0) {
x &= x - 1;
++r;
}
return r;
}
//#endregion BIT_OPERATIONS

1593
libs/jsencrypt/lib/lib/jsrsasign/asn1-1.0.js

File diff suppressed because it is too large

69
libs/jsencrypt/lib/lib/jsrsasign/yahoo.js

@ -0,0 +1,69 @@
/*!
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.9.0
*/
export var YAHOO = {};
YAHOO.lang = {
/**
* Utility to set up the prototype, constructor and superclass properties to
* support an inheritance strategy that can chain constructors and methods.
* Static members will not be inherited.
*
* @method extend
* @static
* @param {Function} subc the object to modify
* @param {Function} superc the object to inherit
* @param {Object} overrides additional properties/methods to add to the
* subclass prototype. These will override the
* matching items obtained from the superclass
* if present.
*/
extend: function (subc, superc, overrides) {
if (!superc || !subc) {
throw new Error("YAHOO.lang.extend failed, please check that " +
"all dependencies are included.");
}
var F = function () { };
F.prototype = superc.prototype;
subc.prototype = new F();
subc.prototype.constructor = subc;
subc.superclass = superc.prototype;
if (superc.prototype.constructor == Object.prototype.constructor) {
superc.prototype.constructor = superc;
}
if (overrides) {
var i;
for (i in overrides) {
subc.prototype[i] = overrides[i];
}
/*
* IE will not enumerate native functions in a derived object even if the
* function was overridden. This is a workaround for specific functions
* we care about on the Object prototype.
* @property _IEEnumFix
* @param {Function} r the object to receive the augmentation
* @param {Function} s the object that supplies the properties to augment
* @static
* @private
*/
var _IEEnumFix = function () { }, ADD = ["toString", "valueOf"];
try {
if (/MSIE/.test(navigator.userAgent)) {
_IEEnumFix = function (r, s) {
for (i = 0; i < ADD.length; i = i + 1) {
var fname = ADD[i], f = s[fname];
if (typeof f === 'function' && f != Object.prototype[fname]) {
r[fname] = f;
}
}
};
}
}
catch (ex) { }
;
_IEEnumFix(subc.prototype, overrides);
}
}
};

1
libs/jsencrypt/lib/version.json

@ -0,0 +1 @@
{"version": "3.3.0"}

34
pages/index/index.js

@ -1,10 +1,10 @@
// index.js
// 获取应用实例
const app = getApp()
import {getIntelligentMessage,getToken,getStaffbasicinfo,clearMessage} from "../../utils/api"
import api, {getIntelligentMessage,getToken,getStaffbasicinfo,clearMessage} from "../../utils/api"
Page({
data: {
selectList:['全部息','居民信息采集','房屋信息采集','社区满意度自查'],
selectList:['全部息','居民信息采集','房屋信息采集','社区满意度自查'],
selectValue:0,
pageSize:10,
pageNo:1,
@ -26,7 +26,9 @@ Page({
await this.getStaffbasicinfo()
},
onShow(){
},
this.getIntelligentMessage()
},
onPullDownRefresh() {
this.setData({
pageNo:1,
@ -139,5 +141,31 @@ onScrollToLower(e){
}).catch(err=>{
console.log(err);
})
},
toDetail(e){
console.log(e);
this.clearOneMessage(e.currentTarget.dataset.item.id)
if(e.currentTarget.dataset.item.msgType == 'resident_base_info'){
wx.navigateTo({
url: `/subpages/addResi/pages/addResi/addResi?type=edit&resiId=${e.currentTarget.dataset.item.targetId}`,
})
}else{
wx.navigateTo({
url: `/subpages/addhouse/pages/addhouse/addhouse?type=edit&houseId=${e.currentTarget.dataset.item.targetId}`,
})
}
this.setData({
[`tableData[${e.currentTarget.dataset.index}].readFlag`]:'1'
})
},
clearOneMessage(id){
let parm= {
msgId:id
}
api.clearOneMessage(parm).then(res=>{
console.log(res);
}).catch(err=>{
console.log(err);
})
}
})

4
pages/index/index.wxml

@ -13,7 +13,7 @@
<view class="select">
<view class="bgBule">
<picker mode="selector" style="display: inline-block;" range="{{selectList}}" value="{{selectValue}}" bindchange="handleChangeFilter" >
<view>{{selectValue == 1?'居民信息采集':selectValue == 2?'房屋信息采集':selectValue == 3?'社区满意度自查':'全部息'}}</view>
<view>{{selectValue == 1?'居民信息采集':selectValue == 2?'房屋信息采集':selectValue == 3?'社区满意度自查':'全部息'}}</view>
</picker>
<image src="../../images/select.png" mode=""/></view>
@ -22,7 +22,7 @@
<view class="content">
<scroll-view class="scroll" scroll-y="{{true}}" lower-threshold="{{ lowerThreshold }}" bindscrolltolower="onScrollToLower">
<view class="box">
<view class="card" wx:for="{{tableData}}" wx:key="index" >
<view class="card" wx:for="{{tableData}}" wx:key="index" data-item="{{item}}" data-index="{{index}}" bind:tap="toDetail">
<view class="left">{{item.createdByName}}</view>
<view class="right">
<view class="top"><text class="title" >{{item.content}}</text> <text class="{{item.readFlag != '1'?'':'gray'}}" style="font-size: 26rpx;">{{item.readFlag != '1'?'未读':'已读'}}</text></view>

7
project.private.config.json

@ -8,6 +8,13 @@
"condition": {
"miniprogram": {
"list": [
{
"name": "修改密码",
"pathName": "subpages/settings/pages/changePassword/changePassword",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "回访记录详情",
"pathName": "subpages/communitySelfInsp/pages/followUpDetail/followUpDetail",

404
subpages/addResi/pages/addResi/addResi.js

@ -158,49 +158,56 @@ Page({
getResiDetail: async function() {
try {
let res = await api.getResiDetail(this.data.resiId);
const {birthday,gender,idNum,mobile,name,nation,houseInfo,categoryInfo,genderName} = res.data;
let result = this.data.residentCategory.filter(item => categoryInfo[item.value] === 1)
const {
birthday,
gender,
idNum,
mobile,
name,
nation,
houseInfo = {}, // 为houseInfo提供一个默认值
categoryInfo,
genderName
} = res.data;
let result = this.data.residentCategory.filter(item => categoryInfo[item.value] === 1);
let residentCategorySty = result.map(item => item.title);
let categoryInfoArr = result.map(item => item.value);
wx.showLoading({
title: '加载中...',
})
await this.setDataAsync({
'form.name':name,
'form.birthday':birthday,
'form.gender':gender,
'form.idNum':idNum,
'form.mobile':mobile,
'form.nation':nation,
'form.gridId' :houseInfo.gridId,
'form.gridName' :houseInfo.gridName,
'form.villageId' :houseInfo.villageId,
'form.buildId' :houseInfo.buildId,
'form.unitId' :houseInfo.unitId,
'form.homeId' :houseInfo.homeId,
'form.houseMergeId':houseInfo.mergeId,
genderName,
categoryInfo:categoryInfoArr,
residentCategorySty,
title: '加载中...',
});
setTimeout(()=>{
this.bindPickerChangeGrid();
},1000)
setTimeout(()=>{
this.bindPickerChangevillageId();
},1500)
setTimeout(()=>{
this.bindPickerChangebuilding()
},2000)
setTimeout(()=>{
this.bindPickerChangeUnit()
},2500)
setTimeout(()=>{
this.bindPickerChangeHouse()
wx.hideLoading()
},3000)
} catch(err) {
this.setDataAsync({
'form.name': name,
'form.birthday': birthday,
'form.gender': gender,
'form.idNum': idNum,
'form.mobile': mobile,
'form.nation': nation,
'form.gridId': houseInfo?.gridId || '', // 使用了可选链
'form.gridName': houseInfo?.gridName || '', // 使用了可选链
'form.villageId': houseInfo?.villageId || '', // 使用了可选链
'form.buildId': houseInfo?.buildId || '', // 使用了可选链
'form.unitId': houseInfo?.unitId || '', // 使用了可选链
'form.homeId': houseInfo?.homeId || '', // 使用了可选链
'form.houseMergeId': houseInfo?.mergeId || '', // 使用了可选链
genderName,
categoryInfo: categoryInfoArr,
residentCategorySty,
});
await this.delay(1000)
await this.bindPickerChangeGrid();
await this.delay(400)
await this.bindPickerChangevillageId();
await this.delay(400)
await this.bindPickerChangebuilding();
await this.delay(400)
await this.bindPickerChangeUnit();
await this.delay(400)
await this.bindPickerChangeHouse();
wx.hideLoading();
} catch (err) {
console.log(err);
}
},
@ -208,6 +215,9 @@ Page({
return new Promise((resolve) => {
this.setData(data, resolve);
});
},
delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
},
// 居住信息详情
getResidentResideInfo(){
@ -242,8 +252,6 @@ Page({
// 获取婚姻信息
getFamilyInfoDetailById(){
api.getFamilyInfoDetailById(this.data.resiId).then(res=>{
console.log(this.data.marriageList);
console.log(res);
this.setData({
'form.familyInfoDto':res.data,
marriageName:this.data.marriageList.filter(item=>item.value ==res.data.marriage)[0].label
@ -385,166 +393,176 @@ Page({
onShareAppMessage() {
},
// 获取网格列表
bindPickerChangeGrid(e){
if (this.data.isFirstLoadGrid) {
// 编辑回填逻辑
const id = this.data.form.gridId;
console.log(id);
console.log(this.data.gridList);
const temp = this.data.gridList.filter(item => item.value == id);
console.log(temp);
let gridName = ''
if(temp.length != 0){
gridName = temp[0].label
}else{
this.showToast('网格信息有误')
return
async bindPickerChangeGrid() {
return new Promise(async (resolve, reject) => {
if (this.data.isFirstLoadGrid) {
// 编辑回填逻辑
const id = this.data.form.gridId;
const temp = this.data.gridList.filter(item => item.value == id);
let gridName = ''
if(temp.length != 0){
gridName = temp[0].label
}else{
this.showToast('网格信息有误')
return
}
this.setData({
'form.gridName': gridName,
"form.gridId": id
});
this.getQuartersOptions(id);
this.setData({
isFirstLoadGrid: false
});
} else {
// 正常修改逻辑
const selectedIndex = e.detail.value;
const selectedVillage = this.data.gridList[selectedIndex];
this.setData({
'form.gridName': selectedVillage.label,
"form.gridId": selectedVillage.value,
'form.villageId':'',
'form.buildId':'',
'form.unitId':'',
'form.homeId':'',
villageName:'',
villageList:[],
buildingName:'',
buildingList:[],
unitName:'',
unitList:[],
houseName:'',
houseList:[],
});
this.getQuartersOptions(selectedVillage.value);
}
this.setData({
'form.gridName': gridName,
"form.gridId": id
});
this.getQuartersOptions(id);
this.setData({
isFirstLoadGrid: false
});
} else {
// 正常修改逻辑
const selectedIndex = e.detail.value;
const selectedVillage = this.data.gridList[selectedIndex];
this.setData({
'form.gridName': selectedVillage.label,
"form.gridId": selectedVillage.value,
'form.villageId':'',
'form.buildId':'',
'form.unitId':'',
'form.homeId':'',
villageName:'',
villageList:[],
buildingName:'',
buildingList:[],
unitName:'',
unitList:[],
houseName:'',
houseList:[],
});
this.getQuartersOptions(selectedVillage.value);
}
resolve();
});
},
bindPickerChangevillageId(e) {
if (this.data.isFirstLoadVillage) {
// 编辑回填逻辑
const id = this.data.form.villageId;
const temp = this.data.villageList.filter(item => item.value == id);
let villageName = ''
if(temp.length != 0){
villageName = temp[0].label
}else{
this.showToast('小区信息有误')
return
}
this.setData({
villageName: villageName,
"form.villageId": id
});
this.getBuildingoption(id);
this.setData({
isFirstLoadVillage: false
});
console.log(this.data.villageList,'小区');
} else {
// 正常修改逻辑
const selectedIndex = e.detail.value;
const selectedVillage = this.data.villageList[selectedIndex];
this.setData({
villageName: selectedVillage.label,
"form.villageId": selectedVillage.value,
'form.buildId':'',
'form.unitId':'',
'form.homeId':'',
buildingName:'',
buildingList:[],
unitName:'',
unitList:[],
houseName:'',
houseList:[],
});
this.getBuildingoption(selectedVillage.value);
}
return new Promise((resolve, reject) => {
if (this.data.isFirstLoadVillage) {
// 编辑回填逻辑
const id = this.data.form.villageId;
const temp = this.data.villageList.filter(item => item.value == id);
let villageName = ''
if(temp.length != 0){
villageName = temp[0].label
}else{
this.showToast('小区信息有误')
return
}
this.setData({
villageName: villageName,
"form.villageId": id
});
this.getBuildingoption(id);
this.setData({
isFirstLoadVillage: false
});
console.log(this.data.villageList,'小区');
} else {
// 正常修改逻辑
const selectedIndex = e.detail.value;
const selectedVillage = this.data.villageList[selectedIndex];
this.setData({
villageName: selectedVillage.label,
"form.villageId": selectedVillage.value,
'form.buildId':'',
'form.unitId':'',
'form.homeId':'',
buildingName:'',
buildingList:[],
unitName:'',
unitList:[],
houseName:'',
houseList:[],
});
this.getBuildingoption(selectedVillage.value);
}
resolve();
});
},
bindPickerChangebuilding(e){
if (this.data.isFirstLoadBuilding) {
const id = this.data.form.buildId;
const temp = this.data.buildingList.filter(item => item.value == id);
let buildingName = ''
if(temp.length != 0){
buildingName = temp[0].label
}else{
this.showToast('小区信息有误')
return
}
this.setData({
buildingName: buildingName,
"form.buildId": id
});
this.getUnitoption(id);
this.setData({
isFirstLoadBuilding: false
});
} else {
const selectedIndex = e.detail.value;
const selectedVillage = this.data.buildingList[selectedIndex];
this.setData({
buildingName: selectedVillage.label,
"form.buildId": selectedVillage.value,
'form.unitId':'',
'form.homeId':'',
unitName:'',
unitList:[],
houseName:'',
houseList:[],
});
this.getUnitoption(selectedVillage.value);
}
return new Promise((resolve, reject) => {
if (this.data.isFirstLoadBuilding) {
const id = this.data.form.buildId;
const temp = this.data.buildingList.filter(item => item.value == id);
let buildingName = ''
if(temp.length != 0){
buildingName = temp[0].label
}else{
this.showToast('小区信息有误')
return
}
this.setData({
buildingName: buildingName,
"form.buildId": id
});
this.getUnitoption(id);
this.setData({
isFirstLoadBuilding: false
});
} else {
const selectedIndex = e.detail.value;
const selectedVillage = this.data.buildingList[selectedIndex];
this.setData({
buildingName: selectedVillage.label,
"form.buildId": selectedVillage.value,
'form.unitId':'',
'form.homeId':'',
unitName:'',
unitList:[],
houseName:'',
houseList:[],
});
this.getUnitoption(selectedVillage.value);
}
resolve();
});
},
bindPickerChangeUnit(e){
if (this.data.isFirstLoadUnit) {
const id = this.data.form.unitId;
const temp = this.data.unitList.filter(item => item.value == id);
let unitName = ''
if(temp.length != 0){
unitName = temp[0].label
}else{
this.showToast('楼栋信息有误')
return
}
this.setData({
unitName: unitName,
"form.unitId": id,
});
this.getHouseoption(id);
this.setData({
isFirstLoadunit: false
});
} else {
const selectedIndex = e.detail.value;
const selectedVillage = this.data.unitList[selectedIndex];
this.setData({
unitName: selectedVillage.label,
"form.unitId": selectedVillage.value,
'form.homeId':'',
houseName:'',
houseList:[],
});
this.getHouseoption(selectedVillage.value);
}
return new Promise((resolve, reject) => {
if (this.data.isFirstLoadUnit) {
const id = this.data.form.unitId;
const temp = this.data.unitList.filter(item => item.value == id);
let unitName = ''
if(temp.length != 0){
unitName = temp[0].label
}else{
this.showToast('楼栋信息有误')
return
}
this.setData({
unitName: unitName,
"form.unitId": id,
});
this.getHouseoption(id);
this.setData({
isFirstLoadunit: false
});
} else {
const selectedIndex = e.detail.value;
const selectedVillage = this.data.unitList[selectedIndex];
this.setData({
unitName: selectedVillage.label,
"form.unitId": selectedVillage.value,
'form.homeId':'',
houseName:'',
houseList:[],
});
this.getHouseoption(selectedVillage.value);
}
resolve();
});
},
bindPickerChangeHouse(e){
if (this.data.isFirstLoadHouse) {
return new Promise((resolve, reject) => {
if (this.data.isFirstLoadHouse) {
const id = this.data.form.homeId;
const temp = this.data.houseList.filter(item => item.value == id);
let houseName = ''
@ -569,6 +587,8 @@ Page({
"form.homeId": selectedVillage.value
});
}
resolve();
});
},
bindNameInput(e){
this.setData({
@ -726,11 +746,11 @@ Page({
return
}
const parm = {...this.data.form}
console.log(this.data.formType);
if(this.data.formType == 'edit'){
parm.resiId = this.data.resiId
try {
const res = await api.resiEdit(parm)
console.log(res.code);
if(res.code === 0){
wx.showToast({
title: '编辑成功',

278
subpages/addhouse/pages/addhouse/addhouse.js

@ -130,24 +130,22 @@ Page({
'form.sysCoding':res.data.ownerIdCard,
gridId:res.data.gridId
});
setTimeout(()=>{
this.bindPickerChangeGrid();
},1000)
setTimeout(()=>{
this.bindPickerChangeneighborHoodId();
},1500)
setTimeout(()=>{
this.bindPickerChangebuilding()
},2000)
setTimeout(()=>{
this.bindPickerChangeUnit()
wx.hideLoading()
},2500)
await this.delay(1000)
await this.bindPickerChangeGrid();
await this.delay(400)
await this.bindPickerChangeneighborHoodId();
await this.delay(400)
await this.bindPickerChangebuilding();
await this.delay(400)
await this.bindPickerChangeUnit();
wx.hideLoading()
} catch(err) {
console.log(err);
}
},
delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
},
setDataAsync: function(data) {
return new Promise((resolve) => {
this.setData(data, resolve);
@ -259,133 +257,145 @@ Page({
},
// 获取网格列表
bindPickerChangeGrid(e){
if (this.data.isFirstLoadGrid) {
// 编辑回填逻辑
const id = this.data.gridId;
const gridName = this.data.gridList.filter(item => item.value == id)[0].label;
this.setData({
gridName: gridName,
gridId: id
});
this.getQuartersOptions(id);
this.setData({
isFirstLoadGrid: false
});
} else {
// 正常修改逻辑
const selectedIndex = e.detail.value;
const selectedVillage = this.data.gridList[selectedIndex];
this.setData({
gridName:selectedVillage.label,
gridId:selectedVillage.value,
'form.neighborHoodId':'',
'form.buildingId':'',
'form.buildingUnitId':'',
'form.doorName':'',
'form.coding':'',
neighborHoodIdName:'',
neighborHoodIdList:[],
buildingName:'',
buildingList:[],
unitName:'',
unitList:[],
doorName:'',
houseList:[],
});
this.getQuartersOptions(selectedVillage.value);
}
return new Promise(async (resolve, reject) => {
if (this.data.isFirstLoadGrid) {
// 编辑回填逻辑
const id = this.data.gridId;
const gridName = this.data.gridList.filter(item => item.value == id)[0].label;
this.setData({
gridName: gridName,
gridId: id
});
this.getQuartersOptions(id);
this.setData({
isFirstLoadGrid: false
});
} else {
// 正常修改逻辑
const selectedIndex = e.detail.value;
const selectedVillage = this.data.gridList[selectedIndex];
this.setData({
gridName:selectedVillage.label,
gridId:selectedVillage.value,
'form.neighborHoodId':'',
'form.buildingId':'',
'form.buildingUnitId':'',
'form.doorName':'',
'form.coding':'',
neighborHoodIdName:'',
neighborHoodIdList:[],
buildingName:'',
buildingList:[],
unitName:'',
unitList:[],
doorName:'',
houseList:[],
});
this.getQuartersOptions(selectedVillage.value);
}
resolve();
});
},
bindPickerChangeneighborHoodId(e) {
if (this.data.isFirstLoadVillage) {
// 编辑回填逻辑
const id = this.data.form.neighborHoodId;
const neighborHoodIdName = this.data.neighborHoodIdList.filter(item => item.value == id)[0].label;
this.setData({
neighborHoodIdName: neighborHoodIdName,
"form.neighborHoodId": id
});
this.getBuildingoption(id);
this.setData({
isFirstLoadVillage: false
});
} else {
// 正常修改逻辑
const selectedIndex = e.detail.value;
const selectedVillage = this.data.neighborHoodIdList[selectedIndex];
this.setData({
neighborHoodIdName: selectedVillage.label,
"form.neighborHoodId": selectedVillage.value,
'form.buildingId':'',
'form.buildingUnitId':'',
'form.doorName':'',
'form.coding':'',
buildingName:'',
buildingList:[],
unitName:'',
unitList:[],
doorName:'',
houseList:[],
});
this.getBuildingoption(selectedVillage.value);
}
return new Promise(async (resolve, reject) => {
if (this.data.isFirstLoadVillage) {
// 编辑回填逻辑
const id = this.data.form.neighborHoodId;
const neighborHoodIdName = this.data.neighborHoodIdList.filter(item => item.value == id)[0].label;
this.setData({
neighborHoodIdName: neighborHoodIdName,
"form.neighborHoodId": id
});
this.getBuildingoption(id);
this.setData({
isFirstLoadVillage: false
});
} else {
// 正常修改逻辑
const selectedIndex = e.detail.value;
const selectedVillage = this.data.neighborHoodIdList[selectedIndex];
this.setData({
neighborHoodIdName: selectedVillage.label,
"form.neighborHoodId": selectedVillage.value,
'form.buildingId':'',
'form.buildingUnitId':'',
'form.doorName':'',
'form.coding':'',
buildingName:'',
buildingList:[],
unitName:'',
unitList:[],
doorName:'',
houseList:[],
});
this.getBuildingoption(selectedVillage.value);
}
resolve();
});
},
bindPickerChangebuilding(e){
if (this.data.isFirstLoadBuilding) {
const id = this.data.form.buildingId;
const buildingName = this.data.buildingList.filter(item => item.value == id)[0].label;
this.setData({
buildingName: buildingName,
"form.buildingId": id
});
this.getUnitoption(id);
this.setData({
isFirstLoadBuilding: false
});
} else {
const selectedIndex = e.detail.value;
const selectedVillage = this.data.buildingList[selectedIndex];
this.setData({
buildingName: selectedVillage.label,
"form.buildingId": selectedVillage.value,
'form.buildingUnitId':'',
'form.doorName':'',
'form.coding':'',
unitName:'',
unitList:[],
doorName:'',
houseList:[],
});
this.getUnitoption(selectedVillage.value);
}
return new Promise(async (resolve, reject) => {
if (this.data.isFirstLoadBuilding) {
const id = this.data.form.buildingId;
const buildingName = this.data.buildingList.filter(item => item.value == id)[0].label;
this.setData({
buildingName: buildingName,
"form.buildingId": id
});
this.getUnitoption(id);
this.setData({
isFirstLoadBuilding: false
});
} else {
const selectedIndex = e.detail.value;
const selectedVillage = this.data.buildingList[selectedIndex];
this.setData({
buildingName: selectedVillage.label,
"form.buildingId": selectedVillage.value,
'form.buildingUnitId':'',
'form.doorName':'',
'form.coding':'',
unitName:'',
unitList:[],
doorName:'',
houseList:[],
});
this.getUnitoption(selectedVillage.value);
}
resolve();
});
},
bindPickerChangeUnit(e){
if (this.data.isFirstLoadUnit) {
const id = this.data.form.buildingUnitId;
const unitName = this.data.unitList.filter(item => item.value == id)[0].label;
this.setData({
unitName: unitName,
"form.buildingUnitId": id,
});
this.getHouseoption(id);
this.setData({
isFirstLoadunit: false
});
} else {
const selectedIndex = e.detail.value;
const selectedVillage = this.data.unitList[selectedIndex];
this.setData({
unitName: selectedVillage.label,
"form.buildingUnitId": selectedVillage.value,
'form.doorName':'',
'form.coding':'',
doorName:'',
});
this.getHouseoption(selectedVillage.value);
}
return new Promise(async (resolve, reject) => {
if (this.data.isFirstLoadUnit) {
const id = this.data.form.buildingUnitId;
const unitName = this.data.unitList.filter(item => item.value == id)[0].label;
this.setData({
unitName: unitName,
"form.buildingUnitId": id,
});
this.getHouseoption(id);
this.setData({
isFirstLoadunit: false
});
} else {
const selectedIndex = e.detail.value;
const selectedVillage = this.data.unitList[selectedIndex];
this.setData({
unitName: selectedVillage.label,
"form.buildingUnitId": selectedVillage.value,
'form.doorName':'',
'form.coding':'',
doorName:'',
});
this.getHouseoption(selectedVillage.value);
}
resolve();
});
},
// bindPickerChangeHouse(e){
// if (this.data.isFirstLoadHouse) {

4
subpages/communitySelfInsp/pages/followUpDetail/followUpDetail.js

@ -40,7 +40,9 @@ Page({
navigationHeight: app.globalData.deviceInfo.navigationHeight,
formType:options.type
})
this.getFollowUpDetail(temp.id)
if(this.data.formType == 'edit'){
this.getFollowUpDetail(temp.id)
}
if(options.type == 'add'){
this.setData({
resiInfo:temp,

4
subpages/communitySelfInsp/pages/followUpDetail/followUpDetail.wxml

@ -10,7 +10,7 @@
<view class="title"> {{resiInfo.reporterName}} {{resiInfo.reporterMobile}}</view>
<view wx:for="{{resiInfo.reasons}}" wx:key="index">
<!-- -->
<view class="reason">不满意原因:{{item.reason}}</view>
<view class="reason">不满意原因1:{{item.reason}}</view>
<view class="gray" style="font-size: 28rpx;margin-top: 20rpx;">不满意类别:{{item.categoryName}}</view>
</view>
@ -19,7 +19,7 @@
<image class="{{showAll?'down_image':'up_image'}}" src="../../../../images/back.png" mode="" bind:tap="handleClickDown"/>
</view>
<view style="margin-top: 20rpx;" wx:if="{{formType == 'add'}}">
不满意原因:{{resiInfo.reason?resiInfo.reason:'--'}}
不满意原因2:{{resiInfo.reason?resiInfo.reason:'--'}}
</view>
</view>
<view class="content_form">

163
subpages/settings/pages/changePassword/changePassword.js

@ -0,0 +1,163 @@
// subpages/settings/pages/changePassword/changePassword.js
import {encryptedData} from "../../../../utils/index"
import api from "../../../../utils/api"
Page({
/**
* 页面的初始数据
*/
data: {
pubKey:'',
oldPassword:"",
newPassword:"",
confirmPassword:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getPubKey()
},
getPubKey(){
api.getPubKey().then(res=>{
this.setData({
pubKey:res.data
})
}).catch(err=>{
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
changeOldPassword(e){
this.setData({
oldPassword:e.detail.value
})
},
changeNewPassword(e){
this.setData({
newPassword:e.detail.value
})
},
changeConfirmPassword(e){
this.setData({
confirmPassword:e.detail.value
})
},
validateComplexity(pwd) {
let regex = new RegExp("(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z]).{8,20}");
if (!regex.test(pwd)) return false;
return true;
},
handelSubmit(e){
if(!this.data.oldPassword){
wx.showToast({
title: '原密码不能为空',
icon:"none"
})
return
}
if(!this.data.newPassword){
wx.showToast({
title: '新密码不能为空',
icon:"none"
})
return
}
if(!this.data.confirmPassword){
wx.showToast({
title: '确认密码不能为空',
icon:"none"
})
return
}
if(!this.data.confirmPassword === this.data.newPassword){
wx.showToast({
title: '两次密码不一致',
icon:"none"
})
return
}
if (!this.validateComplexity(this.data.newPassword)) {
wx.showToast({
title: '密码必须8-20个字符,而且同时包含大小写字母和数字',
icon:"none",
duration:5000
})
return
};
let obj={
oldPassword: encryptedData(this.data.pubKey, this.data.oldPassword),
newPassword: encryptedData(this.data.pubKey, this.data.newPassword),
confirmNewPassword: encryptedData(this.data.pubKey,this.data.confirmPassword),
}
api.changePassword(obj).then(res=>{
console.log(res);
if(res.code == 0){
wx.showToast({
title: '修改成功',
duration:3000,
success:function(){
setTimeout(()=>{
wx.reLaunch({
url: '/pages/login/login',
})
},3000)
}
})
}
}).catch(err=>{
console.log(err);
})
}
})

4
subpages/settings/pages/changePassword/changePassword.json

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "修改密码"
}

23
subpages/settings/pages/changePassword/changePassword.wxml

@ -0,0 +1,23 @@
<!--subpages/settings/pages/changePassword/changePassword.wxml-->
<view class="card">
<view class="item">
<view class="label">原密码</view>
<view class="input">
<input bindinput="changeOldPassword" type="password" placeholder="请输入"/>
</view>
</view>
<view class="item">
<view class="label">新密码</view>
<view class="input">
<input bindinput="changeNewPassword" type="password" placeholder="8-12个字符,同时包含大小写字母和数字"/>
</view>
</view>
<view class="item no-pseudo">
<view class="label">确认密码</view>
<view class="input">
<input bindinput="changeConfirmPassword" type="password" placeholder="请输入"/>
</view>
</view>
</view>
<button hover-class="btn-hover" bind:tap="handelSubmit">提交</button>

50
subpages/settings/pages/changePassword/changePassword.wxss

@ -0,0 +1,50 @@
/* subpages/settings/pages/changePassword/changePassword.wxss */
page{
padding:20rpx;
box-sizing: border-box;
overflow: hidden;
background-color: #f7f7f7;
}
.card{
background-color: #fff;
border-radius: 20rpx;
}
.card .item{
display: flex;
padding: 10rpx 30rpx;
height: 100rpx;
align-items: center;
position: relative;
}
.card .item::before{
content: "";
position: absolute;
left: 30rpx;
right: 30rpx;
bottom: 0;
border-bottom: 2rpx solid #EAEAEA;
}
.no-pseudo::before {
display: none;
}
.card .item .label{
width:150rpx ;
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 500;
color: #333333;
}
button{
background: linear-gradient(to right, #82b4fd, #3e93fe);
font-size: 33rpx;
width: 600rpx !important;
height: 84rpx;
text-align: center;
color: #fff;
border-radius: 84rpx;
position: fixed;
bottom: 100rpx;
left: 50%;
transform: translateX(-300rpx);
}

5
subpages/settings/pages/index/index.js

@ -85,5 +85,10 @@ Page({
}
})
},
toChangePassword(){
wx.navigateTo({
url: '/subpages/settings/pages/changePassword/changePassword',
})
}
})

2
subpages/settings/pages/index/index.wxml

@ -12,7 +12,7 @@
</view>
<image src="../../../../images/right.png" mode=""/>
</view>
<view class="item">
<view class="item" bind:tap="toChangePassword">
<view class="left">
修改密码
</view>

17
utils/api.js

@ -41,12 +41,27 @@ module.exports = {
getDemandoption,
addMeasure,
getFollowUpDetail,
clockRecords
clockRecords,
clearOneMessage,
getPubKey,
changePassword
}
// 获取公钥
function getPubKey () {
return fly.post(`auth/govweb/getKey`)
}
function changePassword (parm) {
return fly.post(`epmetuser/customerstaff/changePassword`,parm)
}
// 消息列表
function getIntelligentMessage(param){
return fly.get(`message/intelligentMessage/page`,param)
}
function clearOneMessage (parm) {
return fly.post(`message/intelligentMessage/msg/clearOne/?msgId=${parm.msgId}`)
}
function clearMessage () {
return fly.post('message/intelligentMessage/msg/clear')
}

6
utils/config.js

@ -1,6 +1,5 @@
module.exports = {
BASEURL: BASEURL,
WEBROOT: WEBROOT,
Token: getToken,
userId: ""
};
@ -9,10 +8,7 @@ module.exports = {
return 'https://epmet-preview.elinkservice.cn/api/' // 演示环境
// return 'http://192.168.1.144/api/' //测试环境
}
function WEBROOT() {
return 'https://lyljdgs.qingdaoshibei.cn/app/mobileapp/qlsb/index.aspx'
}
function getToken() {
return wx.getStorageSync("token");

11
utils/index.js

@ -0,0 +1,11 @@
const JSEncrypt = require('../libs/jsencrypt/lib/index').default;
export function encryptedData(key, data) {
// 新建JSEncrypt对象
let encryptor = new JSEncrypt();
// 设置公钥
encryptor.setPublicKey(key);
// 加密数据
return encryptor.encrypt(data);
}

1
utils/util.js

@ -18,7 +18,6 @@ const formatTime = date => {
let newContent= html.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;"');
return newContent
}
module.exports = {
formatTime: formatTime,
formatRichText: formatRichText

Loading…
Cancel
Save