{@link KJUR.asn1.x509} - ASN.1 structure for X.509 certificate and CRL
- *
{@link KJUR.crypto} - Java Cryptographic Extension(JCE) style MessageDigest/Signature
- * class and utilities
- *
- *
- * NOTE: Please ignore method summary and document of this namespace. This caused by a bug of jsdoc2.
- * @name KJUR
- * @namespace kjur's class library name space
- */
-var KJUR = {};
-
-/**
- * kjur's ASN.1 class library name space
- *
- * This is ITU-T X.690 ASN.1 DER encoder class library and
- * class structure and methods is very similar to
- * org.bouncycastle.asn1 package of
- * well known BouncyCaslte Cryptography Library.
- *
PROVIDING ASN.1 PRIMITIVES
- * Here are ASN.1 DER primitive classes.
- *
- *
0x01 {@link KJUR.asn1.DERBoolean}
- *
0x02 {@link KJUR.asn1.DERInteger}
- *
0x03 {@link KJUR.asn1.DERBitString}
- *
0x04 {@link KJUR.asn1.DEROctetString}
- *
0x05 {@link KJUR.asn1.DERNull}
- *
0x06 {@link KJUR.asn1.DERObjectIdentifier}
- *
0x0a {@link KJUR.asn1.DEREnumerated}
- *
0x0c {@link KJUR.asn1.DERUTF8String}
- *
0x12 {@link KJUR.asn1.DERNumericString}
- *
0x13 {@link KJUR.asn1.DERPrintableString}
- *
0x14 {@link KJUR.asn1.DERTeletexString}
- *
0x16 {@link KJUR.asn1.DERIA5String}
- *
0x17 {@link KJUR.asn1.DERUTCTime}
- *
0x18 {@link KJUR.asn1.DERGeneralizedTime}
- *
0x30 {@link KJUR.asn1.DERSequence}
- *
0x31 {@link KJUR.asn1.DERSet}
- *
- *
OTHER ASN.1 CLASSES
- *
- *
{@link KJUR.asn1.ASN1Object}
- *
{@link KJUR.asn1.DERAbstractString}
- *
{@link KJUR.asn1.DERAbstractTime}
- *
{@link KJUR.asn1.DERAbstractStructured}
- *
{@link KJUR.asn1.DERTaggedObject}
- *
- *
SUB NAME SPACES
- *
- *
{@link KJUR.asn1.cades} - CAdES long term signature format
- * NOTE1: 'params' can be omitted.
- * NOTE2: 'obj' parameter have been supported since
- * asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).
- * @example
- * // default constructor
- * o = new KJUR.asn1.DERBitString();
- * // initialize with binary string
- * o = new KJUR.asn1.DERBitString({bin: "1011"});
- * // initialize with boolean array
- * o = new KJUR.asn1.DERBitString({array: [true,false,true,true]});
- * // initialize with hexadecimal string (04 is unused bits)
- * o = new KJUR.asn1.DEROctetString({hex: "04bac0"});
- * // initialize with ASN1Util.newObject argument for encapsulated
- * o = new KJUR.asn1.DERBitString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
- * // above generates a ASN.1 data like this:
- * // BIT STRING, encapsulates {
- * // SEQUENCE {
- * // INTEGER 3
- * // PrintableString 'aaa'
- * // }
- * // }
- */
-KJUR.asn1.DERBitString = function(params) {
- if (params !== undefined && typeof params.obj !== "undefined") {
- var o = KJUR.asn1.ASN1Util.newObject(params.obj);
- params.hex = "00" + o.getEncodedHex();
- }
- KJUR.asn1.DERBitString.superclass.constructor.call(this);
- this.hT = "03";
-
- /**
- * set ASN.1 value(V) by a hexadecimal string including unused bits
- * @name setHexValueIncludingUnusedBits
- * @memberOf KJUR.asn1.DERBitString#
- * @function
- * @param {String} newHexStringIncludingUnusedBits
- */
- this.setHexValueIncludingUnusedBits = function(newHexStringIncludingUnusedBits) {
- this.hTLV = null;
- this.isModified = true;
- this.hV = newHexStringIncludingUnusedBits;
- };
-
- /**
- * set ASN.1 value(V) by unused bit and hexadecimal string of value
- * @name setUnusedBitsAndHexValue
- * @memberOf KJUR.asn1.DERBitString#
- * @function
- * @param {Integer} unusedBits
- * @param {String} hValue
- */
- this.setUnusedBitsAndHexValue = function(unusedBits, hValue) {
- if (unusedBits < 0 || 7 < unusedBits) {
- throw "unused bits shall be from 0 to 7: u = " + unusedBits;
- }
- var hUnusedBits = "0" + unusedBits;
- this.hTLV = null;
- this.isModified = true;
- this.hV = hUnusedBits + hValue;
- };
-
- /**
- * set ASN.1 DER BitString by binary string
- * @name setByBinaryString
- * @memberOf KJUR.asn1.DERBitString#
- * @function
- * @param {String} binaryString binary value string (i.e. '10111')
- * @description
- * Its unused bits will be calculated automatically by length of
- * 'binaryValue'.
- * NOTE: Trailing zeros '0' will be ignored.
- * @example
- * o = new KJUR.asn1.DERBitString();
- * o.setByBooleanArray("01011");
- */
- this.setByBinaryString = function(binaryString) {
- binaryString = binaryString.replace(/0+$/, '');
- var unusedBits = 8 - binaryString.length % 8;
- if (unusedBits == 8) unusedBits = 0;
- for (var i = 0; i <= unusedBits; i++) {
- binaryString += '0';
- }
- var h = '';
- for (var i = 0; i < binaryString.length - 1; i += 8) {
- var b = binaryString.substr(i, 8);
- var x = parseInt(b, 2).toString(16);
- if (x.length == 1) x = '0' + x;
- h += x;
- }
- this.hTLV = null;
- this.isModified = true;
- this.hV = '0' + unusedBits + h;
- };
-
- /**
- * set ASN.1 TLV value(V) by an array of boolean
- * @name setByBooleanArray
- * @memberOf KJUR.asn1.DERBitString#
- * @function
- * @param {array} booleanArray array of boolean (ex. [true, false, true])
- * @description
- * NOTE: Trailing falses will be ignored in the ASN.1 DER Object.
- * @example
- * o = new KJUR.asn1.DERBitString();
- * o.setByBooleanArray([false, true, false, true, true]);
- */
- this.setByBooleanArray = function(booleanArray) {
- var s = '';
- for (var i = 0; i < booleanArray.length; i++) {
- if (booleanArray[i] == true) {
- s += '1';
- } else {
- s += '0';
- }
- }
- this.setByBinaryString(s);
- };
-
- /**
- * generate an array of falses with specified length
- * @name newFalseArray
- * @memberOf KJUR.asn1.DERBitString
- * @function
- * @param {Integer} nLength length of array to generate
- * @return {array} array of boolean falses
- * @description
- * This static method may be useful to initialize boolean array.
- * @example
- * o = new KJUR.asn1.DERBitString();
- * o.newFalseArray(3) → [false, false, false]
- */
- this.newFalseArray = function(nLength) {
- var a = new Array(nLength);
- for (var i = 0; i < nLength; i++) {
- a[i] = false;
- }
- return a;
- };
-
- this.getFreshValueHex = function() {
- return this.hV;
- };
-
- if (typeof params != "undefined") {
- if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) {
- this.setHexValueIncludingUnusedBits(params);
- } else if (typeof params['hex'] != "undefined") {
- this.setHexValueIncludingUnusedBits(params['hex']);
- } else if (typeof params['bin'] != "undefined") {
- this.setByBinaryString(params['bin']);
- } else if (typeof params['array'] != "undefined") {
- this.setByBooleanArray(params['array']);
- }
- }
-};
-YAHOO.lang.extend(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER OctetString
- * @name KJUR.asn1.DEROctetString
- * @class class for ASN.1 DER OctetString
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
- * @extends KJUR.asn1.DERAbstractString
- * @description
- * This class provides ASN.1 OctetString simple type.
- * Supported "params" attributes are:
- *
- *
str - to set a string as a value
- *
hex - to set a hexadecimal string as a value
- *
obj - to set a encapsulated ASN.1 value by JSON object
- * which is defined in {@link KJUR.asn1.ASN1Util.newObject}
- *
- * NOTE: A parameter 'obj' have been supported
- * for "OCTET STRING, encapsulates" structure.
- * since asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).
- * @see KJUR.asn1.DERAbstractString - superclass
- * @example
- * // default constructor
- * o = new KJUR.asn1.DEROctetString();
- * // initialize with string
- * o = new KJUR.asn1.DEROctetString({str: "aaa"});
- * // initialize with hexadecimal string
- * o = new KJUR.asn1.DEROctetString({hex: "616161"});
- * // initialize with ASN1Util.newObject argument
- * o = new KJUR.asn1.DEROctetString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
- * // above generates a ASN.1 data like this:
- * // OCTET STRING, encapsulates {
- * // SEQUENCE {
- * // INTEGER 3
- * // PrintableString 'aaa'
- * // }
- * // }
- */
-KJUR.asn1.DEROctetString = function(params) {
- if (params !== undefined && typeof params.obj !== "undefined") {
- var o = KJUR.asn1.ASN1Util.newObject(params.obj);
- params.hex = o.getEncodedHex();
- }
- KJUR.asn1.DEROctetString.superclass.constructor.call(this, params);
- this.hT = "04";
-};
-YAHOO.lang.extend(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER Null
- * @name KJUR.asn1.DERNull
- * @class class for ASN.1 DER Null
- * @extends KJUR.asn1.ASN1Object
- * @description
- * @see KJUR.asn1.ASN1Object - superclass
- */
-KJUR.asn1.DERNull = function() {
- KJUR.asn1.DERNull.superclass.constructor.call(this);
- this.hT = "05";
- this.hTLV = "0500";
-};
-YAHOO.lang.extend(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER ObjectIdentifier
- * @name KJUR.asn1.DERObjectIdentifier
- * @class class for ASN.1 DER ObjectIdentifier
- * @param {Array} params associative array of parameters (ex. {'oid': '2.5.4.5'})
- * @extends KJUR.asn1.ASN1Object
- * @description
- *
- * As for argument 'params' for constructor, you can specify one of
- * following properties:
- *
- *
oid - specify initial ASN.1 value(V) by a oid string (ex. 2.5.4.13)
- *
hex - specify initial ASN.1 value(V) by a hexadecimal string
- *
- * NOTE: 'params' can be omitted.
- */
-KJUR.asn1.DERObjectIdentifier = function(params) {
- var itox = function(i) {
- var h = i.toString(16);
- if (h.length == 1) h = '0' + h;
- return h;
- };
- var roidtox = function(roid) {
- var h = '';
- var bi = new BigInteger(roid, 10);
- var b = bi.toString(2);
- var padLen = 7 - b.length % 7;
- if (padLen == 7) padLen = 0;
- var bPad = '';
- for (var i = 0; i < padLen; i++) bPad += '0';
- b = bPad + b;
- for (var i = 0; i < b.length - 1; i += 7) {
- var b8 = b.substr(i, 7);
- if (i != b.length - 7) b8 = '1' + b8;
- h += itox(parseInt(b8, 2));
- }
- return h;
- };
-
- KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this);
- this.hT = "06";
-
- /**
- * set value by a hexadecimal string
- * @name setValueHex
- * @memberOf KJUR.asn1.DERObjectIdentifier#
- * @function
- * @param {String} newHexString hexadecimal value of OID bytes
- */
- this.setValueHex = function(newHexString) {
- this.hTLV = null;
- this.isModified = true;
- this.s = null;
- this.hV = newHexString;
- };
-
- /**
- * set value by a OID string
- * @name setValueOidString
- * @memberOf KJUR.asn1.DERObjectIdentifier#
- * @function
- * @param {String} oidString OID string (ex. 2.5.4.13)
- * @example
- * o = new KJUR.asn1.DERObjectIdentifier();
- * o.setValueOidString("2.5.4.13");
- */
- this.setValueOidString = function(oidString) {
- if (! oidString.match(/^[0-9.]+$/)) {
- throw "malformed oid string: " + oidString;
- }
- var h = '';
- var a = oidString.split('.');
- var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
- h += itox(i0);
- a.splice(0, 2);
- for (var i = 0; i < a.length; i++) {
- h += roidtox(a[i]);
- }
- this.hTLV = null;
- this.isModified = true;
- this.s = null;
- this.hV = h;
- };
-
- /**
- * set value by a OID name
- * @name setValueName
- * @memberOf KJUR.asn1.DERObjectIdentifier#
- * @function
- * @param {String} oidName OID name (ex. 'serverAuth')
- * @since 1.0.1
- * @description
- * OID name shall be defined in 'KJUR.asn1.x509.OID.name2oidList'.
- * Otherwise raise error.
- * @example
- * o = new KJUR.asn1.DERObjectIdentifier();
- * o.setValueName("serverAuth");
- */
- this.setValueName = function(oidName) {
- var oid = KJUR.asn1.x509.OID.name2oid(oidName);
- if (oid !== '') {
- this.setValueOidString(oid);
- } else {
- throw "DERObjectIdentifier oidName undefined: " + oidName;
- }
- };
-
- this.getFreshValueHex = function() {
- return this.hV;
- };
-
- if (params !== undefined) {
- if (typeof params === "string") {
- if (params.match(/^[0-2].[0-9.]+$/)) {
- this.setValueOidString(params);
- } else {
- this.setValueName(params);
- }
- } else if (params.oid !== undefined) {
- this.setValueOidString(params.oid);
- } else if (params.hex !== undefined) {
- this.setValueHex(params.hex);
- } else if (params.name !== undefined) {
- this.setValueName(params.name);
- }
- }
-};
-YAHOO.lang.extend(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER Enumerated
- * @name KJUR.asn1.DEREnumerated
- * @class class for ASN.1 DER Enumerated
- * @extends KJUR.asn1.ASN1Object
- * @description
- *
- * As for argument 'params' for constructor, you can specify one of
- * following properties:
- *
- *
int - specify initial ASN.1 value(V) by integer value
- *
hex - specify initial ASN.1 value(V) by a hexadecimal string
- *
- * NOTE: 'params' can be omitted.
- * @example
- * new KJUR.asn1.DEREnumerated(123);
- * new KJUR.asn1.DEREnumerated({int: 123});
- * new KJUR.asn1.DEREnumerated({hex: '1fad'});
- */
-KJUR.asn1.DEREnumerated = function(params) {
- KJUR.asn1.DEREnumerated.superclass.constructor.call(this);
- this.hT = "0a";
-
- /**
- * set value by Tom Wu's BigInteger object
- * @name setByBigInteger
- * @memberOf KJUR.asn1.DEREnumerated#
- * @function
- * @param {BigInteger} bigIntegerValue to set
- */
- this.setByBigInteger = function(bigIntegerValue) {
- this.hTLV = null;
- this.isModified = true;
- this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
- };
-
- /**
- * set value by integer value
- * @name setByInteger
- * @memberOf KJUR.asn1.DEREnumerated#
- * @function
- * @param {Integer} integer value to set
- */
- this.setByInteger = function(intValue) {
- var bi = new BigInteger(String(intValue), 10);
- this.setByBigInteger(bi);
- };
-
- /**
- * set value by integer value
- * @name setValueHex
- * @memberOf KJUR.asn1.DEREnumerated#
- * @function
- * @param {String} hexadecimal string of integer value
- * @description
- *
- * NOTE: Value shall be represented by minimum octet length of
- * two's complement representation.
- */
- this.setValueHex = function(newHexString) {
- this.hV = newHexString;
- };
-
- this.getFreshValueHex = function() {
- return this.hV;
- };
-
- if (typeof params != "undefined") {
- if (typeof params['int'] != "undefined") {
- this.setByInteger(params['int']);
- } else if (typeof params == "number") {
- this.setByInteger(params);
- } else if (typeof params['hex'] != "undefined") {
- this.setValueHex(params['hex']);
- }
- }
-};
-YAHOO.lang.extend(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER UTF8String
- * @name KJUR.asn1.DERUTF8String
- * @class class for ASN.1 DER UTF8String
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
- * @extends KJUR.asn1.DERAbstractString
- * @description
- * @see KJUR.asn1.DERAbstractString - superclass
- */
-KJUR.asn1.DERUTF8String = function(params) {
- KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params);
- this.hT = "0c";
-};
-YAHOO.lang.extend(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER NumericString
- * @name KJUR.asn1.DERNumericString
- * @class class for ASN.1 DER NumericString
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
- * @extends KJUR.asn1.DERAbstractString
- * @description
- * @see KJUR.asn1.DERAbstractString - superclass
- */
-KJUR.asn1.DERNumericString = function(params) {
- KJUR.asn1.DERNumericString.superclass.constructor.call(this, params);
- this.hT = "12";
-};
-YAHOO.lang.extend(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER PrintableString
- * @name KJUR.asn1.DERPrintableString
- * @class class for ASN.1 DER PrintableString
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
- * @extends KJUR.asn1.DERAbstractString
- * @description
- * @see KJUR.asn1.DERAbstractString - superclass
- */
-KJUR.asn1.DERPrintableString = function(params) {
- KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params);
- this.hT = "13";
-};
-YAHOO.lang.extend(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER TeletexString
- * @name KJUR.asn1.DERTeletexString
- * @class class for ASN.1 DER TeletexString
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
- * @extends KJUR.asn1.DERAbstractString
- * @description
- * @see KJUR.asn1.DERAbstractString - superclass
- */
-KJUR.asn1.DERTeletexString = function(params) {
- KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params);
- this.hT = "14";
-};
-YAHOO.lang.extend(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER IA5String
- * @name KJUR.asn1.DERIA5String
- * @class class for ASN.1 DER IA5String
- * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
- * @extends KJUR.asn1.DERAbstractString
- * @description
- * @see KJUR.asn1.DERAbstractString - superclass
- */
-KJUR.asn1.DERIA5String = function(params) {
- KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
- this.hT = "16";
-};
-YAHOO.lang.extend(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER UTCTime
- * @name KJUR.asn1.DERUTCTime
- * @class class for ASN.1 DER UTCTime
- * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
- * @extends KJUR.asn1.DERAbstractTime
- * @description
- *
- * As for argument 'params' for constructor, you can specify one of
- * following properties:
- *
- *
str - specify initial ASN.1 value(V) by a string (ex.'130430235959Z')
- *
hex - specify initial ASN.1 value(V) by a hexadecimal string
- *
date - specify Date object.
- *
- * NOTE: 'params' can be omitted.
- *
EXAMPLES
- * @example
- * d1 = new KJUR.asn1.DERUTCTime();
- * d1.setString('130430125959Z');
- *
- * d2 = new KJUR.asn1.DERUTCTime({'str': '130430125959Z'});
- * d3 = new KJUR.asn1.DERUTCTime({'date': new Date(Date.UTC(2015, 0, 31, 0, 0, 0, 0))});
- * d4 = new KJUR.asn1.DERUTCTime('130430125959Z');
- */
-KJUR.asn1.DERUTCTime = function(params) {
- KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params);
- this.hT = "17";
-
- /**
- * set value by a Date object
- * @name setByDate
- * @memberOf KJUR.asn1.DERUTCTime#
- * @function
- * @param {Date} dateObject Date object to set ASN.1 value(V)
- * @example
- * o = new KJUR.asn1.DERUTCTime();
- * o.setByDate(new Date("2016/12/31"));
- */
- this.setByDate = function(dateObject) {
- this.hTLV = null;
- this.isModified = true;
- this.date = dateObject;
- this.s = this.formatDate(this.date, 'utc');
- this.hV = stohex(this.s);
- };
-
- this.getFreshValueHex = function() {
- if (typeof this.date == "undefined" && typeof this.s == "undefined") {
- this.date = new Date();
- this.s = this.formatDate(this.date, 'utc');
- this.hV = stohex(this.s);
- }
- return this.hV;
- };
-
- if (params !== undefined) {
- if (params.str !== undefined) {
- this.setString(params.str);
- } else if (typeof params == "string" && params.match(/^[0-9]{12}Z$/)) {
- this.setString(params);
- } else if (params.hex !== undefined) {
- this.setStringHex(params.hex);
- } else if (params.date !== undefined) {
- this.setByDate(params.date);
- }
- }
-};
-YAHOO.lang.extend(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER GeneralizedTime
- * @name KJUR.asn1.DERGeneralizedTime
- * @class class for ASN.1 DER GeneralizedTime
- * @param {Array} params associative array of parameters (ex. {'str': '20130430235959Z'})
- * @property {Boolean} withMillis flag to show milliseconds or not
- * @extends KJUR.asn1.DERAbstractTime
- * @description
- *
- * As for argument 'params' for constructor, you can specify one of
- * following properties:
- *
- *
str - specify initial ASN.1 value(V) by a string (ex.'20130430235959Z')
- *
hex - specify initial ASN.1 value(V) by a hexadecimal string
- *
date - specify Date object.
- *
millis - specify flag to show milliseconds (from 1.0.6)
- *
- * NOTE1: 'params' can be omitted.
- * NOTE2: 'withMillis' property is supported from asn1 1.0.6.
- */
-KJUR.asn1.DERGeneralizedTime = function(params) {
- KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params);
- this.hT = "18";
- this.withMillis = false;
-
- /**
- * set value by a Date object
- * @name setByDate
- * @memberOf KJUR.asn1.DERGeneralizedTime#
- * @function
- * @param {Date} dateObject Date object to set ASN.1 value(V)
- * @example
- * When you specify UTC time, use 'Date.UTC' method like this:
- * o1 = new DERUTCTime();
- * o1.setByDate(date);
- *
- * date = new Date(Date.UTC(2015, 0, 31, 23, 59, 59, 0)); #2015JAN31 23:59:59
- */
- this.setByDate = function(dateObject) {
- this.hTLV = null;
- this.isModified = true;
- this.date = dateObject;
- this.s = this.formatDate(this.date, 'gen', this.withMillis);
- this.hV = stohex(this.s);
- };
-
- this.getFreshValueHex = function() {
- if (this.date === undefined && this.s === undefined) {
- this.date = new Date();
- this.s = this.formatDate(this.date, 'gen', this.withMillis);
- this.hV = stohex(this.s);
- }
- return this.hV;
- };
-
- if (params !== undefined) {
- if (params.str !== undefined) {
- this.setString(params.str);
- } else if (typeof params == "string" && params.match(/^[0-9]{14}Z$/)) {
- this.setString(params);
- } else if (params.hex !== undefined) {
- this.setStringHex(params.hex);
- } else if (params.date !== undefined) {
- this.setByDate(params.date);
- }
- if (params.millis === true) {
- this.withMillis = true;
- }
- }
-};
-YAHOO.lang.extend(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER Sequence
- * @name KJUR.asn1.DERSequence
- * @class class for ASN.1 DER Sequence
- * @extends KJUR.asn1.DERAbstractStructured
- * @description
- *
- * As for argument 'params' for constructor, you can specify one of
- * following properties:
- *
- *
array - specify array of ASN1Object to set elements of content
- *
- * NOTE: 'params' can be omitted.
- */
-KJUR.asn1.DERSequence = function(params) {
- KJUR.asn1.DERSequence.superclass.constructor.call(this, params);
- this.hT = "30";
- this.getFreshValueHex = function() {
- var h = '';
- for (var i = 0; i < this.asn1Array.length; i++) {
- var asn1Obj = this.asn1Array[i];
- h += asn1Obj.getEncodedHex();
- }
- this.hV = h;
- return this.hV;
- };
-};
-YAHOO.lang.extend(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER Set
- * @name KJUR.asn1.DERSet
- * @class class for ASN.1 DER Set
- * @extends KJUR.asn1.DERAbstractStructured
- * @description
- *
- * As for argument 'params' for constructor, you can specify one of
- * following properties:
- *
- *
array - specify array of ASN1Object to set elements of content
- *
sortflag - flag for sort (default: true). ASN.1 BER is not sorted in 'SET OF'.
- *
- * NOTE1: 'params' can be omitted.
- * NOTE2: sortflag is supported since 1.0.5.
- */
-KJUR.asn1.DERSet = function(params) {
- KJUR.asn1.DERSet.superclass.constructor.call(this, params);
- this.hT = "31";
- this.sortFlag = true; // item shall be sorted only in ASN.1 DER
- this.getFreshValueHex = function() {
- var a = new Array();
- for (var i = 0; i < this.asn1Array.length; i++) {
- var asn1Obj = this.asn1Array[i];
- a.push(asn1Obj.getEncodedHex());
- }
- if (this.sortFlag == true) a.sort();
- this.hV = a.join('');
- return this.hV;
- };
-
- if (typeof params != "undefined") {
- if (typeof params.sortflag != "undefined" &&
- params.sortflag == false)
- this.sortFlag = false;
- }
-};
-YAHOO.lang.extend(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured);
-
-// ********************************************************************
-/**
- * class for ASN.1 DER TaggedObject
- * @name KJUR.asn1.DERTaggedObject
- * @class class for ASN.1 DER TaggedObject
- * @extends KJUR.asn1.ASN1Object
- * @description
- *
- * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object.
- * For example, if you find '[1]' tag in a ASN.1 dump,
- * 'tagNoHex' will be 'a1'.
- *
- * As for optional argument 'params' for constructor, you can specify *ANY* of
- * following properties:
- *
- *
explicit - specify true if this is explicit tag otherwise false
- * (default is 'true').
- *
tag - specify tag (default is 'a0' which means [0])
- *
obj - specify ASN1Object which is tagged
- *
- * @example
- * d1 = new KJUR.asn1.DERUTF8String({'str':'a'});
- * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1});
- * hex = d2.getEncodedHex();
- */
-KJUR.asn1.DERTaggedObject = function(params) {
- KJUR.asn1.DERTaggedObject.superclass.constructor.call(this);
- this.hT = "a0";
- this.hV = '';
- this.isExplicit = true;
- this.asn1Object = null;
-
- /**
- * set value by an ASN1Object
- * @name setString
- * @memberOf KJUR.asn1.DERTaggedObject#
- * @function
- * @param {Boolean} isExplicitFlag flag for explicit/implicit tag
- * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag
- * @param {ASN1Object} asn1Object ASN.1 to encapsulate
- */
- this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) {
- this.hT = tagNoHex;
- this.isExplicit = isExplicitFlag;
- this.asn1Object = asn1Object;
- if (this.isExplicit) {
- this.hV = this.asn1Object.getEncodedHex();
- this.hTLV = null;
- this.isModified = true;
- } else {
- this.hV = null;
- this.hTLV = asn1Object.getEncodedHex();
- this.hTLV = this.hTLV.replace(/^../, tagNoHex);
- this.isModified = false;
- }
- };
-
- this.getFreshValueHex = function() {
- return this.hV;
- };
-
- if (typeof params != "undefined") {
- if (typeof params['tag'] != "undefined") {
- this.hT = params['tag'];
- }
- if (typeof params['explicit'] != "undefined") {
- this.isExplicit = params['explicit'];
- }
- if (typeof params['obj'] != "undefined") {
- this.asn1Object = params['obj'];
- this.setASN1Object(this.isExplicit, this.hT, this.asn1Object);
- }
- }
-};
-YAHOO.lang.extend(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object);
-
-/**
- * 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) {
- // Parse the public key.
- 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 {
- 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));
-
-/**
- *
- * @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) {
- options = options || {};
- this.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 = "3.0.0-rc.1";
- return JSEncrypt;
-}());
-
-// window.JSEncrypt = JSEncrypt;
-
-exports.JSEncrypt = JSEncrypt;
-exports.default = JSEncrypt;
-
-Object.defineProperty(exports, '__esModule', { value: true });
-
-})));
diff --git a/assets/js/jsencrypt/rsa.js b/assets/js/jsencrypt/rsa.js
index c00da71..de00d52 100644
--- a/assets/js/jsencrypt/rsa.js
+++ b/assets/js/jsencrypt/rsa.js
@@ -1,6 +1,4 @@
-// import JSEncrypt from '../jsencrypt/jsencrypt'
-// import JSEncrypt from '../jsencrypt/jsencryptInit'
import JSEncrypt from '../jsencrypt/jsencryptInit'
export function encrypt(publicKey, message) {
const encrypt = new JSEncrypt()
diff --git a/components/dateMonth/dateMonth.js b/components/dateMonth/dateMonth.js
new file mode 100644
index 0000000..3e78082
--- /dev/null
+++ b/components/dateMonth/dateMonth.js
@@ -0,0 +1,29 @@
+const date = new Date()
+const years = []
+const months = []
+
+for (let i = 1990; i <= date.getFullYear(); i++) {
+ years.push(i)
+}
+
+for (let i = 1; i <= 12; i++) {
+ months.push(i)
+}
+
+Page({
+ data: {
+ years: years,
+ year: date.getFullYear(),
+ months: months,
+ month: 2,
+ value: [9999, 1, 1],
+ },
+ bindChange: function (e) {
+ const val = e.detail.value
+ this.setData({
+ year: this.data.years[val[0]],
+ month: this.data.months[val[1]],
+ })
+ console.log(this.data)
+ }
+})
\ No newline at end of file
diff --git a/pages/work/work.json b/components/dateMonth/dateMonth.json
similarity index 56%
rename from pages/work/work.json
rename to components/dateMonth/dateMonth.json
index 8835af0..e8cfaaf 100644
--- a/pages/work/work.json
+++ b/components/dateMonth/dateMonth.json
@@ -1,3 +1,4 @@
{
+ "component": true,
"usingComponents": {}
}
\ No newline at end of file
diff --git a/components/dateMonth/dateMonth.wxml b/components/dateMonth/dateMonth.wxml
new file mode 100644
index 0000000..9641485
--- /dev/null
+++ b/components/dateMonth/dateMonth.wxml
@@ -0,0 +1,14 @@
+
+
+ {{year}}年{{month}}月
+
+
+ {{item}}年
+
+
+ {{item}}月
+
+
+
+
\ No newline at end of file
diff --git a/components/dateMonth/dateMonth.wxss b/components/dateMonth/dateMonth.wxss
new file mode 100644
index 0000000..8688561
--- /dev/null
+++ b/components/dateMonth/dateMonth.wxss
@@ -0,0 +1,16 @@
+.box{
+ height: 300px;
+}
+.title{
+ width: 100%;
+ text-align: center;
+ margin: 20px 0;
+}
+.item{
+ text-align: center;
+ line-height: 50px
+}
+.intro {
+ margin: 30px;
+ text-align: center;
+}
\ No newline at end of file
diff --git a/pages/data/data.js b/pages/data/data.js
deleted file mode 100644
index 3349a12..0000000
--- a/pages/data/data.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// pages/meeting/meeting.js
-Page({
-
- /**
- * 页面的初始数据
- */
- data: {
-
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
-
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
-})
\ No newline at end of file
diff --git a/pages/data/data.json b/pages/data/data.json
deleted file mode 100644
index 8835af0..0000000
--- a/pages/data/data.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "usingComponents": {}
-}
\ No newline at end of file
diff --git a/pages/data/data.wxml b/pages/data/data.wxml
deleted file mode 100644
index 11cc61d..0000000
--- a/pages/data/data.wxml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- 资料网员
-
diff --git a/pages/data/data.wxss b/pages/data/data.wxss
deleted file mode 100644
index 94874ac..0000000
--- a/pages/data/data.wxss
+++ /dev/null
@@ -1,20 +0,0 @@
-/* pages/meeting/meeting.wxss */
-.select-list {
- height: 92rpx;
- display: flex;
- align-items: center;
- background-color: #F5F5F5;
-}
-
-.select-item {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-.select-item image {
- width: 21rpx;
- height: 12rpx;
- margin-left: 20rpx;
-}
\ No newline at end of file
diff --git a/pages/home/home.js b/pages/home/home.js
index 20a4c59..589bde9 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -20,13 +20,15 @@ Page({
if(index === 0) { // 来款项目
url = '../project/project'
} else if(index === 1) { // 工作组
- url = '../work/work'
+ // url = '../work/work'
+ url = '../project/project'
} else if(index === 2) { // 分标委
url = '../committee/committee'
} else if(index === 3) { // 会议活动
url = '../meeting/meeting'
} else{ // 资料网员
- url = '../data/data'
+ // url = '../data/data'
+ url = '../project/project'
}
wx.navigateTo({
url,
diff --git a/pages/login/login.js b/pages/login/login.js
index c549268..5deea2f 100644
--- a/pages/login/login.js
+++ b/pages/login/login.js
@@ -1,6 +1,6 @@
// pages/mine/mine.js
import UserApi from '../../assets/js/http/userApi'
-import {JSEncrypt} from '../../assets/js/jsencrypt/jsencrypt'
+import { encrypt } from '../../assets/js/jsencrypt/rsa'
var countdown = 60; // 倒计时秒数
Page({
data: {
@@ -65,26 +65,37 @@ Page({
},
// 登录
formSubmit(e) {
- console.log('form发生了submit事件,携带数据为:', e.detail.value)
if (e.detail.value.phone && e.detail.value.captcha) {
- wx.showLoading({
- title: '正在登录...',
- icon: 'loading'
- })
- // 新建JSEncrypt对象
- let encrypt = new JSEncrypt()
- encrypt.setPublicKey(this.data.rsaPublicKey) // 公钥加密
let params = {
- username: encrypt.encrypt(e.detail.value.phone), // 手机号加密
+ username: encrypt(this.data.rsaPublicKey,e.detail.value.phone), // 手机号加密
captcha: e.detail.value.captcha,
rsaPublicKey: this.data.rsaPublicKey
}
// 请求短信登录start
UserApi.codeLogin(params).then(res => {
if (res.success) {
- wx.hideLoading()
+ // 存token和userInfo
+ wx.setStorage({
+ key: 'X-Access-Token',
+ data: res.result.token
+ })
+ wx.setStorage({
+ key: 'userInfo',
+ data: res.result.userInfo
+ })
+ if(res.message === "updatePassword") {
+ // 跳转设置密码页
+ wx.navigateTo({
+ url: '../setPassword/setPassword',
+ })
+ }else{
+ // 跳转设置密码页
+ wx.switchTab({
+ url: '../home/home',
+ })
+ }
+
} else {
- wx.hideLoading()
wx.showToast({
title: '登录失败',
icon: 'error',
@@ -99,9 +110,6 @@ Page({
icon: 'none',
duration: 2000
})
- wx.navigateTo({
- url: '../setPassword/setPassword',
- })
}
},
@@ -128,6 +136,10 @@ Page({
this.setData({
rsaPublicKey: res.result
})
+ wx.setStorage({
+ key: 'rsaPublicKey',
+ data: res.result
+ })
}
})
},
diff --git a/pages/mine/mine.js b/pages/mine/mine.js
index a6407c1..4d6dae2 100644
--- a/pages/mine/mine.js
+++ b/pages/mine/mine.js
@@ -1,11 +1,12 @@
// pages/mine/mine.js
+import UserApi from '../../assets/js/http/userApi'
Page({
/**
* 页面的初始数据
*/
data: {
-
+ userId: ''
},
// 个人信息
mineInfo(){
@@ -41,11 +42,31 @@ Page({
url: '../mineContract/mineContract',
})
},
+ // 退出登录
+ logout(){
+ wx.showModal({
+ cancelColor: '取消',
+ content: '确定退出登录?',
+ confirmColor: '#069F99',
+ success (res) {
+ if (res.confirm) {
+ UserApi.logout().then(res=>{
+ if(res.success){
+ wx.clearStorage()
+ wx.redirectTo({
+ url: '../login/login',
+ })
+ }
+ })
+ } else if (res.cancel) {}
+ }
+ })
+ },
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
+
},
/**
diff --git a/pages/mine/mine.wxml b/pages/mine/mine.wxml
index 9864347..5331f1b 100644
--- a/pages/mine/mine.wxml
+++ b/pages/mine/mine.wxml
@@ -72,6 +72,6 @@
- 退出登录
+ 退出登录
\ No newline at end of file
diff --git a/pages/mineData/mineData.js b/pages/mineData/mineData.js
index b6cb894..7bbc726 100644
--- a/pages/mineData/mineData.js
+++ b/pages/mineData/mineData.js
@@ -1,65 +1,41 @@
+import UserApi from '../../assets/js/http/userApi'
Page({
/**
* 页面的初始数据
*/
data: {
- list: [1,1,1,1,,1,1,1]
+ list: [],
+ pageNo: 1,
+ pageSize: 10
},
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
-
+ loadData(){
+ let params = {
+ pageNo: this.data.pageNo,
+ pageSize: this.data.pageSize
+ }
+ UserApi.dataList(params).then(res=>{
+ if(res.success){
+ console.log(res.result.records)
+ this.setData({
+ list: res.result.records
+ })
+ }
+ })
},
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
+ this.loadData()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
+ this.data.pageNo++
+ this.loadData()
}
})
\ No newline at end of file
diff --git a/pages/mineData/mineData.json b/pages/mineData/mineData.json
index b10fba0..bce8669 100644
--- a/pages/mineData/mineData.json
+++ b/pages/mineData/mineData.json
@@ -1,4 +1,4 @@
{
- "navigationBarTitleText": "我的资料",
+ "navigationBarTitleText": "资料下载",
"usingComponents": {}
}
\ No newline at end of file
diff --git a/pages/mineData/mineData.wxml b/pages/mineData/mineData.wxml
index a299962..86dbad9 100644
--- a/pages/mineData/mineData.wxml
+++ b/pages/mineData/mineData.wxml
@@ -1,13 +1,8 @@
- 2021-10-12 12:00:00
+ {{item.uploadTime}}
- 1文件名称列表文件名称列表文件名称列表文件名称列表.PDF
- 2文件名称列表文件名称列表文件名称列表文件名称列表.PDF
- 3文件名称文件名称列表文件名称列表.PDF
- 4文件名称列表文件名称列表文件名称列表文件名称列表.PDF
- 5文件名称列表文件名称列表文件名称列表文件名称列表.PDF
- 6文件名称.PDF
+ {{item.fileName}}
diff --git a/pages/setPassword/setPassword.js b/pages/setPassword/setPassword.js
index 7a8c091..075aab2 100644
--- a/pages/setPassword/setPassword.js
+++ b/pages/setPassword/setPassword.js
@@ -1,6 +1,6 @@
// pages/meeting/meeting.js
import UserApi from '../../assets/js/http/userApi'
-import {JSEncrypt} from '../../assets/js/jsencrypt/jsencrypt'
+import { encrypt } from '../../assets/js/jsencrypt/rsa'
Page({
/**
* 页面的初始数据
@@ -67,26 +67,19 @@ Page({
return
}
if (this.data.flag) {
- wx.showLoading({
- title: '正在登录...',
- icon: 'loading'
- })
- // 新建JSEncrypt对象
- let encrypt = new JSEncrypt()
- encrypt.setPublicKey(this.data.rsaPublicKey) // 公钥加密
let params = {
- newPassword: encrypt.encrypt(e.detail.value.newPassword),
- verifyPassword: encrypt.encrypt(e.detail.value.verifyPassword),
+ newPassword: encrypt(this.data.rsaPublicKey, e.detail.value.newPassword),
+ verifyPassword: encrypt(this.data.rsaPublicKey, e.detail.value.verifyPassword),
rsaPublicKey: this.data.rsaPublicKey
}
- console.log('form发生了submit事件,携带数据为:', e.detail.value)
// 请求短信登录start
UserApi.setPassword(params).then(res => {
- console.log(res)
if (res.success) {
- wx.hideLoading()
+ // 成功设置密码,跳转首页
+ wx.navigateTo({
+ url: '../home/home',
+ })
} else {
- wx.hideLoading()
wx.showToast({
title: '登录失败',
icon: 'error',
@@ -108,18 +101,23 @@ Page({
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
-
+
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
- UserApi.getRSAPublicKey().then(res => {
- if (res.success) {
- this.setData({
- rsaPublicKey: res.result
+ const that = this
+ wx.getStorage({
+ key: 'rsaPublicKey',
+ success (res) {
+ that.setData({
+ rsaPublicKey: res.data
})
+ },
+ fail: function(){
+ // 缓存中没有登录过默认app.json的登录页
}
})
},
diff --git a/pages/upDateInfo/upDateInfo.js b/pages/upDateInfo/upDateInfo.js
index 4d62d13..d7e59ac 100644
--- a/pages/upDateInfo/upDateInfo.js
+++ b/pages/upDateInfo/upDateInfo.js
@@ -1,8 +1,6 @@
// pages/meeting/meeting.js
import UserApi from '../../assets/js/http/userApi'
-import {
- JSEncrypt
-} from '../../assets/js/jsencrypt/jsencrypt'
+import { encrypt } from '../../assets/js/jsencrypt/rsa'
var countdown = 60; // 倒计时秒数
Page({
@@ -21,11 +19,16 @@ Page({
},
showGetCaptcha: true
},
+ bindInputPhone(e) {
+ this.setData({
+ "form.phone": e.detail.value
+ })
+ },
// 获取验证码
getVerCode() {
- if (/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(this.data.phone)) {
+ if (/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(this.data.form.phone)) {
UserApi.sendCode({
- phone: this.data.phone
+ phone: this.data.form.phone
}).then(res => {
// 获取成功,倒计时 start
if (res.success) {
@@ -121,50 +124,33 @@ Page({
return
}
console.log('form发生了submit事件,携带数据为:', e.detail.value)
- // 新建JSEncrypt对象
- let encrypt = new JSEncrypt()
- encrypt.setPublicKey(this.data.rsaPublicKey) // 公钥加密
let params = {
- phone: encrypt.encrypt(e.detail.value.phone),
+ phone: encrypt(this.data.rsaPublicKey, e.detail.value.phone),
+ newPassword: encrypt(this.data.rsaPublicKey, e.detail.value.newPassword),
+ verifyPassword: encrypt(this.data.rsaPublicKey, e.detail.value.verifyPassword),
verifyCode: e.detail.value.verifyCode,
- newPassword: encrypt.encrypt(e.detail.value.newPassword),
- verifyPassword: encrypt.encrypt(e.detail.value.verifyPassword)
+ rsaPublicKey: this.data.rsaPublicKey,
+ }
+ console.log(params)
+ if(this.data.flag){
+ UserApi.updatePassword(params).then(res => {
+ console.log(res)
+ if(res.success){
+ wx.showToast({
+ title: res.result,
+ })
+ wx.navigateBack()
+ }
+ }).catch(err => {
+ wx.hideToast()
+ })
}
- UserApi.updatePassword(params).then(res => {
- console.log(res)
- wx.hideToast()
- }).catch(err => {
- wx.hideToast()
- })
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
- // 性别处理
- if (this.data.form.gender === '1') {
- this.data.sexArr[0].checked = "true"
- this.setData({
- sexArr: this.data.sexArr,
- })
- console.log(this.data.sexArr)
- }
- if (this.data.form.gender === '2') {
- this.data.sexArr[1].checked = "true"
- this.setData({
- sexArr: this.data.sexArr,
- })
- console.log(2)
- }
- let params = {
- id: wx.getStorage('id') // 用户id
- }
- UserApi.mineInfo(params).then(res => {
- console.log(res)
- wx.hideToast()
- }).catch(err => {
- wx.hideToast()
- })
+
},
/**
@@ -178,41 +164,17 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
+ const that = this
+ wx.getStorage({
+ key: 'rsaPublicKey',
+ success (res) {
+ that.setData({
+ rsaPublicKey: res.data
+ })
+ },
+ fail: function(){
+ // 缓存中没有登录过默认app.json的登录页
+ }
+ })
}
})
\ No newline at end of file
diff --git a/pages/upDateInfo/upDateInfo.wxml b/pages/upDateInfo/upDateInfo.wxml
index 85fc705..c6039bd 100644
--- a/pages/upDateInfo/upDateInfo.wxml
+++ b/pages/upDateInfo/upDateInfo.wxml
@@ -4,7 +4,7 @@
手机号
-
+
diff --git a/pages/work/work.js b/pages/work/work.js
deleted file mode 100644
index 3349a12..0000000
--- a/pages/work/work.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// pages/meeting/meeting.js
-Page({
-
- /**
- * 页面的初始数据
- */
- data: {
-
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
-
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
-})
\ No newline at end of file
diff --git a/pages/work/work.wxml b/pages/work/work.wxml
deleted file mode 100644
index 0ae85f2..0000000
--- a/pages/work/work.wxml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- 工作组
-
diff --git a/pages/work/work.wxss b/pages/work/work.wxss
deleted file mode 100644
index 94874ac..0000000
--- a/pages/work/work.wxss
+++ /dev/null
@@ -1,20 +0,0 @@
-/* pages/meeting/meeting.wxss */
-.select-list {
- height: 92rpx;
- display: flex;
- align-items: center;
- background-color: #F5F5F5;
-}
-
-.select-item {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-.select-item image {
- width: 21rpx;
- height: 12rpx;
- margin-left: 20rpx;
-}
\ No newline at end of file
diff --git a/project.config.json b/project.config.json
index 63cab1d..04f042f 100644
--- a/project.config.json
+++ b/project.config.json
@@ -22,9 +22,9 @@
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
- "useMultiFrameRuntime": false,
- "useApiHook": false,
- "useApiHostProcess": false,
+ "useMultiFrameRuntime": true,
+ "useApiHook": true,
+ "useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],