Commit 993c6f60 authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

v3.4.0

parent f6a6b4a6
......@@ -21,7 +21,6 @@ class ASN1DERDecoder {
asn1obj.identifier = ASN1Identifier(nextValue);
if (asn1obj.identifier.isConstructed()) {
var contentData = loadSubContent(iterator: iterator);
if (contentData.isEmpty) {
......@@ -39,9 +38,7 @@ class ASN1DERDecoder {
item.parent = asn1obj;
}
} else {
if (asn1obj.identifier.typeClass() == ASN1IdentifierClass.UNIVERSAL) {
var contentData = loadSubContent(iterator: iterator);
asn1obj.encoded = Uint8List.fromList(contentData);
......@@ -52,75 +49,62 @@ class ASN1DERDecoder {
if (tagNumber == ASN1IdentifierTagNumber.END_OF_CONTENT) {
return result;
}
else if (tagNumber == ASN1IdentifierTagNumber.BOOLEAN) {
} else if (tagNumber == ASN1IdentifierTagNumber.BOOLEAN) {
var value = contentData.length > 0 ? contentData.first : null;
if (value != null) {
asn1obj.value = value > 0 ? true : false;
}
}
else if (tagNumber == ASN1IdentifierTagNumber.INTEGER) {
} else if (tagNumber == ASN1IdentifierTagNumber.INTEGER) {
while (contentData.length > 0 && contentData.first == 0) {
contentData.removeAt(0); // remove not significant digit
}
asn1obj.value = contentData;
}
else if (tagNumber == ASN1IdentifierTagNumber.NULL) {
} else if (tagNumber == ASN1IdentifierTagNumber.NULL) {
asn1obj.value = null;
}
else if (tagNumber == ASN1IdentifierTagNumber.OBJECT_IDENTIFIER) {
} else if (tagNumber == ASN1IdentifierTagNumber.OBJECT_IDENTIFIER) {
asn1obj.value = decodeOid(contentData: contentData);
}
else if ([
} else if ([
ASN1IdentifierTagNumber.UTF8_STRING,
ASN1IdentifierTagNumber.PRINTABLE_STRING,
ASN1IdentifierTagNumber.NUMERIC_STRING,
ASN1IdentifierTagNumber.GENERAL_STRING,
ASN1IdentifierTagNumber.UNIVERSAL_STRING,
ASN1IdentifierTagNumber.CHARACTER_STRING,
ASN1IdentifierTagNumber.T61_STRING].contains(tagNumber)) {
ASN1IdentifierTagNumber.T61_STRING
].contains(tagNumber)) {
asn1obj.value = utf8.decode(contentData, allowMalformed: true);
}
else if (tagNumber == ASN1IdentifierTagNumber.BMP_STRING) {
} else if (tagNumber == ASN1IdentifierTagNumber.BMP_STRING) {
asn1obj.value = String.fromCharCodes(contentData);
}
else if ([
} else if ([
ASN1IdentifierTagNumber.VISIBLE_STRING,
ASN1IdentifierTagNumber.IA5_STRING
].contains(tagNumber)) {
asn1obj.value = ascii.decode(contentData, allowInvalid: true);
}
else if (tagNumber == ASN1IdentifierTagNumber.UTC_TIME) {
} else if (tagNumber == ASN1IdentifierTagNumber.UTC_TIME) {
asn1obj.value = utcTimeToDate(contentData: contentData);
}
else if (tagNumber == ASN1IdentifierTagNumber.GENERALIZED_TIME) {
} else if (tagNumber == ASN1IdentifierTagNumber.GENERALIZED_TIME) {
asn1obj.value = generalizedTimeToDate(contentData: contentData);
}
else if (tagNumber == ASN1IdentifierTagNumber.BIT_STRING) {
} else if (tagNumber == ASN1IdentifierTagNumber.BIT_STRING) {
if (contentData.length > 0) {
contentData.removeAt(0); // unused bits
}
asn1obj.value = contentData;
}
else if (tagNumber == ASN1IdentifierTagNumber.OCTET_STRING) {
} else if (tagNumber == ASN1IdentifierTagNumber.OCTET_STRING) {
try {
var subIterator = contentData.iterator;
asn1obj.sub = parse(iterator: subIterator);
} catch (e) {
var str;
try {
str = utf8.decode(contentData);
} catch(e) {}
} catch (e) {}
if (str != null) {
asn1obj.value = str;
} else {
asn1obj.value = contentData;
}
}
}
else {
} else {
// print("unsupported tag: ${asn1obj.identifier.tagNumber()}");
asn1obj.value = contentData;
}
......@@ -132,7 +116,7 @@ class ASN1DERDecoder {
var str;
try {
str = utf8.decode(contentData);
} catch(e) {}
} catch (e) {}
if (str != null) {
asn1obj.value = str;
} else {
......@@ -150,8 +134,8 @@ class ASN1DERDecoder {
if (iterator.moveNext()) {
var first = iterator.current;
if (first != null) {
if ((first & 0x80) != 0) { // long
if ((first & 0x80) != 0) {
// long
var octetsToRead = first - 0x80;
var data = <int>[];
......@@ -165,11 +149,10 @@ class ASN1DERDecoder {
}
return toIntValue(data) ?? BigInt.from(0);
} else { // short
} else {
// short
return BigInt.from(first);
}
}
}
return BigInt.from(0);
......@@ -251,7 +234,7 @@ class ASN1DERDecoder {
String utc;
try {
utc = utf8.decode(contentData);
} catch(e) {}
} catch (e) {}
if (utc == null) {
return null;
}
......@@ -268,36 +251,30 @@ class ASN1DERDecoder {
int end;
String c;
// not just YYMMDDhhmmZ
if(utc.length > 11) {
if (utc.length > 11) {
// get character after minutes
c = utc[10];
end = 10;
// see if seconds are present
if(c != '+' && c != '-') {
if (c != '+' && c != '-') {
// get seconds
ss = int.parse(utc.substring(10, 12), radix: 10);
end += 2;
}
}
var date = DateTime.utc(
year,
MM,
DD,
hh,
mm,
ss,
0
);
if(end != null) {
var date = DateTime.utc(year, MM, DD, hh, mm, ss, 0);
if (end != null) {
// get +/- after end of time
c = utc[end];
if(c == '+' || c == '-') {
if (c == '+' || c == '-') {
// get hours+minutes offset
var hhoffset = int.parse(utc.substring(end + 1, end + 1 + 2), radix: 10);
var mmoffset = int.parse(utc.substring(end + 4, end + 4 + 2), radix: 10);
var hhoffset =
int.parse(utc.substring(end + 1, end + 1 + 2), radix: 10);
var mmoffset =
int.parse(utc.substring(end + 4, end + 4 + 2), radix: 10);
// calculate offset in milliseconds
var offset = hhoffset * 60 + mmoffset;
......@@ -305,7 +282,7 @@ class ASN1DERDecoder {
var offsetDuration = Duration(milliseconds: offset);
// apply offset
if(c == '+') {
if (c == '+') {
date.subtract(offsetDuration);
} else {
date.add(offsetDuration);
......@@ -345,7 +322,7 @@ class ASN1DERDecoder {
String gentime;
try {
gentime = utf8.decode(contentData);
} catch(e) {}
} catch (e) {}
if (gentime == null) {
return null;
}
......@@ -362,23 +339,25 @@ class ASN1DERDecoder {
var offset = 0;
var isUTC = false;
if(gentime[gentime.length - 1] == 'Z') {
if (gentime[gentime.length - 1] == 'Z') {
isUTC = true;
}
var end = gentime.length - 5;
var c = gentime[end];
if(c == '+' || c == '-') {
if (c == '+' || c == '-') {
// get hours+minutes offset
var hhoffset = int.parse(gentime.substring(end + 1, end + 1 + 2), radix: 10);
var mmoffset = int.parse(gentime.substring(end + 4, end + 4 + 2), radix: 10);
var hhoffset =
int.parse(gentime.substring(end + 1, end + 1 + 2), radix: 10);
var mmoffset =
int.parse(gentime.substring(end + 4, end + 4 + 2), radix: 10);
// calculate offset in milliseconds
offset = hhoffset * 60 + mmoffset;
offset *= 60000;
// apply offset
if(c == '+') {
if (c == '+') {
offset *= -1;
}
......@@ -386,26 +365,17 @@ class ASN1DERDecoder {
}
// check for second fraction
if(gentime[14] == '.') {
if (gentime[14] == '.') {
fff = double.parse(gentime.substring(14)) * 1000;
}
var date = DateTime.utc(
YYYY,
MM,
DD,
hh,
mm,
ss,
fff.toInt()
);
if(isUTC) {
var date = DateTime.utc(YYYY, MM, DD, hh, mm, ss, fff.toInt());
if (isUTC) {
var offsetDuration = Duration(milliseconds: offset);
date.add(offsetDuration);
}
return date;
}
}
......@@ -418,15 +388,11 @@ BigInt toIntValue(List<int> data) {
BigInt value = BigInt.from(0);
for (var index = 0; index < data.length; index++) {
var byte = data[index];
value += BigInt.from(byte << 8*(data.length-index-1));
value += BigInt.from(byte << 8 * (data.length - index - 1));
}
return value;
}
class ASN1OutOfBufferError extends Error {
}
class ASN1ParseError extends Error {
class ASN1OutOfBufferError extends Error {}
}
\ No newline at end of file
class ASN1ParseError extends Error {}
......@@ -21,32 +21,45 @@ class ASN1DistinguishedNames {
static ASN1DistinguishedNames fromValue(String oid) {
if (oid != null)
return ASN1DistinguishedNames.values.firstWhere((element) => element.oid() == oid, orElse: () => null);
return ASN1DistinguishedNames.values
.firstWhere((element) => element.oid() == oid, orElse: () => null);
return null;
}
String oid() => _oid;
String representation() => _representation;
@override
String toString() => "($_oid, $_representation)";
static const COMMON_NAME = const ASN1DistinguishedNames._internal("2.5.4.3", "CN");
static const DN_QUALIFIER = const ASN1DistinguishedNames._internal("2.5.4.46", "DNQ");
static const SERIAL_NUMBER = const ASN1DistinguishedNames._internal("2.5.4.5", "SERIALNUMBER");
static const GIVEN_NAME = const ASN1DistinguishedNames._internal("2.5.4.42", "GIVENNAME");
static const SURNAME = const ASN1DistinguishedNames._internal("2.5.4.4", "SURNAME");
static const ORGANIZATIONAL_UNIT_NAME = const ASN1DistinguishedNames._internal("2.5.4.11", "OU");
static const ORGANIZATION_NAME = const ASN1DistinguishedNames._internal("2.5.4.10", "O");
static const STREET_ADDRESS = const ASN1DistinguishedNames._internal("2.5.4.9", "STREET");
static const LOCALITY_NAME = const ASN1DistinguishedNames._internal("2.5.4.7", "L");
static const STATE_OR_PROVINCE_NAME = const ASN1DistinguishedNames._internal("2.5.4.8", "ST");
static const COUNTRY_NAME = const ASN1DistinguishedNames._internal("2.5.4.6", "C");
static const EMAIL = const ASN1DistinguishedNames._internal("1.2.840.113549.1.9.1", "E");
static const COMMON_NAME =
const ASN1DistinguishedNames._internal("2.5.4.3", "CN");
static const DN_QUALIFIER =
const ASN1DistinguishedNames._internal("2.5.4.46", "DNQ");
static const SERIAL_NUMBER =
const ASN1DistinguishedNames._internal("2.5.4.5", "SERIALNUMBER");
static const GIVEN_NAME =
const ASN1DistinguishedNames._internal("2.5.4.42", "GIVENNAME");
static const SURNAME =
const ASN1DistinguishedNames._internal("2.5.4.4", "SURNAME");
static const ORGANIZATIONAL_UNIT_NAME =
const ASN1DistinguishedNames._internal("2.5.4.11", "OU");
static const ORGANIZATION_NAME =
const ASN1DistinguishedNames._internal("2.5.4.10", "O");
static const STREET_ADDRESS =
const ASN1DistinguishedNames._internal("2.5.4.9", "STREET");
static const LOCALITY_NAME =
const ASN1DistinguishedNames._internal("2.5.4.7", "L");
static const STATE_OR_PROVINCE_NAME =
const ASN1DistinguishedNames._internal("2.5.4.8", "ST");
static const COUNTRY_NAME =
const ASN1DistinguishedNames._internal("2.5.4.6", "C");
static const EMAIL =
const ASN1DistinguishedNames._internal("1.2.840.113549.1.9.1", "E");
bool operator ==(value) => value == _oid;
@override
int get hashCode => _oid.hashCode;
}
\ No newline at end of file
}
......@@ -12,7 +12,9 @@ class ASN1IdentifierClass {
static ASN1IdentifierClass fromValue(int value) {
if (value != null)
return ASN1IdentifierClass.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return ASN1IdentifierClass.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -81,41 +83,45 @@ class ASN1IdentifierTagNumber {
static ASN1IdentifierTagNumber fromValue(int value) {
if (value != null)
return ASN1IdentifierTagNumber.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return ASN1IdentifierTagNumber.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
int toValue() => _value;
static const END_OF_CONTENT = const ASN1IdentifierTagNumber._internal(0x00);
static const BOOLEAN = const ASN1IdentifierTagNumber._internal(0x01);
static const INTEGER = const ASN1IdentifierTagNumber._internal(0x02);
static const BIT_STRING = const ASN1IdentifierTagNumber._internal(0x03);
static const OCTET_STRING = const ASN1IdentifierTagNumber._internal(0x04);
static const NULL = const ASN1IdentifierTagNumber._internal(0x05);
static const OBJECT_IDENTIFIER = const ASN1IdentifierTagNumber._internal(0x06);
static const OBJECT_DESCRIPTOR = const ASN1IdentifierTagNumber._internal(0x07);
static const EXTERNAL = const ASN1IdentifierTagNumber._internal(0x08);
static const READ = const ASN1IdentifierTagNumber._internal(0x09);
static const ENUMERATED = const ASN1IdentifierTagNumber._internal(0x0A);
static const EMBEDDED_PDV = const ASN1IdentifierTagNumber._internal(0x0B);
static const UTF8_STRING = const ASN1IdentifierTagNumber._internal(0x0C);
static const RELATIVE_OID = const ASN1IdentifierTagNumber._internal(0x0D);
static const SEQUENCE = const ASN1IdentifierTagNumber._internal(0x10);
static const SET = const ASN1IdentifierTagNumber._internal(0x11);
static const NUMERIC_STRING = const ASN1IdentifierTagNumber._internal(0x12);
static const PRINTABLE_STRING = const ASN1IdentifierTagNumber._internal(0x13);
static const T61_STRING = const ASN1IdentifierTagNumber._internal(0x14);
static const VIDEOTEX_STRING = const ASN1IdentifierTagNumber._internal(0x15);
static const IA5_STRING = const ASN1IdentifierTagNumber._internal(0x16);
static const UTC_TIME = const ASN1IdentifierTagNumber._internal(0x17);
static const GENERALIZED_TIME = const ASN1IdentifierTagNumber._internal(0x18);
static const GRAPHIC_STRING = const ASN1IdentifierTagNumber._internal(0x19);
static const VISIBLE_STRING = const ASN1IdentifierTagNumber._internal(0x1A);
static const GENERAL_STRING = const ASN1IdentifierTagNumber._internal(0x1B);
static const UNIVERSAL_STRING = const ASN1IdentifierTagNumber._internal(0x1C);
static const CHARACTER_STRING = const ASN1IdentifierTagNumber._internal(0x1D);
static const BMP_STRING = const ASN1IdentifierTagNumber._internal(0x1E);
static const END_OF_CONTENT = const ASN1IdentifierTagNumber._internal(0x00);
static const BOOLEAN = const ASN1IdentifierTagNumber._internal(0x01);
static const INTEGER = const ASN1IdentifierTagNumber._internal(0x02);
static const BIT_STRING = const ASN1IdentifierTagNumber._internal(0x03);
static const OCTET_STRING = const ASN1IdentifierTagNumber._internal(0x04);
static const NULL = const ASN1IdentifierTagNumber._internal(0x05);
static const OBJECT_IDENTIFIER =
const ASN1IdentifierTagNumber._internal(0x06);
static const OBJECT_DESCRIPTOR =
const ASN1IdentifierTagNumber._internal(0x07);
static const EXTERNAL = const ASN1IdentifierTagNumber._internal(0x08);
static const READ = const ASN1IdentifierTagNumber._internal(0x09);
static const ENUMERATED = const ASN1IdentifierTagNumber._internal(0x0A);
static const EMBEDDED_PDV = const ASN1IdentifierTagNumber._internal(0x0B);
static const UTF8_STRING = const ASN1IdentifierTagNumber._internal(0x0C);
static const RELATIVE_OID = const ASN1IdentifierTagNumber._internal(0x0D);
static const SEQUENCE = const ASN1IdentifierTagNumber._internal(0x10);
static const SET = const ASN1IdentifierTagNumber._internal(0x11);
static const NUMERIC_STRING = const ASN1IdentifierTagNumber._internal(0x12);
static const PRINTABLE_STRING = const ASN1IdentifierTagNumber._internal(0x13);
static const T61_STRING = const ASN1IdentifierTagNumber._internal(0x14);
static const VIDEOTEX_STRING = const ASN1IdentifierTagNumber._internal(0x15);
static const IA5_STRING = const ASN1IdentifierTagNumber._internal(0x16);
static const UTC_TIME = const ASN1IdentifierTagNumber._internal(0x17);
static const GENERALIZED_TIME = const ASN1IdentifierTagNumber._internal(0x18);
static const GRAPHIC_STRING = const ASN1IdentifierTagNumber._internal(0x19);
static const VISIBLE_STRING = const ASN1IdentifierTagNumber._internal(0x1A);
static const GENERAL_STRING = const ASN1IdentifierTagNumber._internal(0x1B);
static const UNIVERSAL_STRING = const ASN1IdentifierTagNumber._internal(0x1C);
static const CHARACTER_STRING = const ASN1IdentifierTagNumber._internal(0x1D);
static const BMP_STRING = const ASN1IdentifierTagNumber._internal(0x1E);
String toString() {
switch (this.toValue()) {
......@@ -200,11 +206,16 @@ class ASN1Identifier {
}
ASN1IdentifierTagNumber tagNumber() {
return ASN1IdentifierTagNumber.fromValue(rawValue & 0x1F) ?? ASN1IdentifierTagNumber.END_OF_CONTENT;
return ASN1IdentifierTagNumber.fromValue(rawValue & 0x1F) ??
ASN1IdentifierTagNumber.END_OF_CONTENT;
}
ASN1IdentifierClass typeClass() {
for (var tc in [ASN1IdentifierClass.APPLICATION, ASN1IdentifierClass.CONTEXT_SPECIFIC, ASN1IdentifierClass.PRIVATE]) {
for (var tc in [
ASN1IdentifierClass.APPLICATION,
ASN1IdentifierClass.CONTEXT_SPECIFIC,
ASN1IdentifierClass.PRIVATE
]) {
if ((rawValue & tc.toValue()) == tc.toValue()) {
return tc;
}
......@@ -226,4 +237,4 @@ class ASN1Identifier {
String toString() {
return description;
}
}
\ No newline at end of file
}
......@@ -46,12 +46,12 @@ class ASN1Object {
ASN1Object findOid({OID oid, String oidValue}) {
oidValue = oid != null ? oid.toValue() : oidValue;
for (var child in (sub ?? <ASN1Object>[])) {
if (child.identifier?.tagNumber() == ASN1IdentifierTagNumber.OBJECT_IDENTIFIER) {
if (child.identifier?.tagNumber() ==
ASN1IdentifierTagNumber.OBJECT_IDENTIFIER) {
if (child.value == oidValue) {
return child;
}
}
else {
} else {
var result = child.findOid(oidValue: oidValue);
if (result != null) {
return result;
......@@ -66,22 +66,23 @@ class ASN1Object {
}
String printAsn1({insets = ""}) {
var output = insets;
output += identifier?.description?.toUpperCase() ?? "";
output += (value != null ? ": $value" : "");
if (identifier?.typeClass() == ASN1IdentifierClass.UNIVERSAL && identifier?.tagNumber() == ASN1IdentifierTagNumber.OBJECT_IDENTIFIER) {
var descr = OID.fromValue(value?.toString() ?? "")?.name();
if (descr != null) {
output += " ($descr)";
}
}
output += sub != null && sub.length > 0 ? " {" : "";
output += "\n";
for (var item in (sub ?? <ASN1Object>[])) {
output += item.printAsn1(insets: insets + " ");
var output = insets;
output += identifier?.description?.toUpperCase() ?? "";
output += (value != null ? ": $value" : "");
if (identifier?.typeClass() == ASN1IdentifierClass.UNIVERSAL &&
identifier?.tagNumber() == ASN1IdentifierTagNumber.OBJECT_IDENTIFIER) {
var descr = OID.fromValue(value?.toString() ?? "")?.name();
if (descr != null) {
output += " ($descr)";
}
output += sub != null && sub.length > 0 ? "}\n" : "";
return output;
}
output += sub != null && sub.length > 0 ? " {" : "";
output += "\n";
for (var item in (sub ?? <ASN1Object>[])) {
output += item.printAsn1(insets: insets + " ");
}
output += sub != null && sub.length > 0 ? "}\n" : "";
return output;
}
@override
......@@ -95,4 +96,4 @@ class ASN1Object {
}
return null;
}
}
\ No newline at end of file
}
......@@ -16,7 +16,8 @@ class KeyUsage {
].toSet();
static KeyUsage fromIndex(int value) {
return KeyUsage.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return KeyUsage.values.firstWhere((element) => element.toValue() == value,
orElse: () => null);
}
int toValue() => _value;
......
......@@ -103,7 +103,8 @@ class OID {
].toSet();
static OID fromValue(String value) {
return OID.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return OID.values.firstWhere((element) => element.toValue() == value,
orElse: () => null);
}
String toValue() => _value;
......@@ -122,29 +123,40 @@ class OID {
static const ecdsaWithSHA256 = const OID._internal("1.2.840.10045.4.3.2");
static const ecdsaWithSHA512 = const OID._internal("1.2.840.10045.4.3.4");
static const rsaEncryption = const OID._internal("1.2.840.113549.1.1.1");
static const md2WithRSAEncryption = const OID._internal("1.2.840.113549.1.1.2");
static const md4WithRSAEncryption = const OID._internal("1.2.840.113549.1.1.3");
static const md5WithRSAEncryption = const OID._internal("1.2.840.113549.1.1.4");
static const sha1WithRSAEncryption = const OID._internal("1.2.840.113549.1.1.5");
static const md2WithRSAEncryption =
const OID._internal("1.2.840.113549.1.1.2");
static const md4WithRSAEncryption =
const OID._internal("1.2.840.113549.1.1.3");
static const md5WithRSAEncryption =
const OID._internal("1.2.840.113549.1.1.4");
static const sha1WithRSAEncryption =
const OID._internal("1.2.840.113549.1.1.5");
static const RSAES_OAEP = const OID._internal("1.2.840.113549.1.1.7");
static const mgf1 = const OID._internal(".2.840.113549.1.1.8");
static const pSpecified = const OID._internal(".2.840.113549.1.1.9");
static const RSASSA_PSS = const OID._internal(".2.840.113549.1.1.10");
static const sha256WithRSAEncryption = const OID._internal("1.2.840.113549.1.1.11");
static const sha384WithRSAEncryption = const OID._internal("1.2.840.113549.1.1.12");
static const sha512WithRSAEncryption = const OID._internal("1.2.840.113549.1.1.13");
static const sha256WithRSAEncryption =
const OID._internal("1.2.840.113549.1.1.11");
static const sha384WithRSAEncryption =
const OID._internal("1.2.840.113549.1.1.12");
static const sha512WithRSAEncryption =
const OID._internal("1.2.840.113549.1.1.13");
static const pkcs7data = const OID._internal("1.2.840.113549.1.7.1");
static const pkcs7signedData = const OID._internal("1.2.840.113549.1.7.2");
static const pkcs7envelopedData = const OID._internal("1.2.840.113549.1.7.3");
static const emailAddress = const OID._internal("1.2.840.113549.1.9.1");
static const signingCertificateV2 = const OID._internal("1.2.840.113549.1.9.16.2.47");
static const signingCertificateV2 =
const OID._internal("1.2.840.113549.1.9.16.2.47");
static const contentType = const OID._internal("1.2.840.113549.1.9.3");
static const messageDigest = const OID._internal("1.2.840.113549.1.9.4");
static const signingTime = const OID._internal("1.2.840.113549.1.9.5");
static const dsaWithSha1 = const OID._internal("1.2.840.10040.4.3");
static const certificateExtension = const OID._internal("1.3.6.1.4.1.11129.2.4.2");
static const jurisdictionOfIncorporationSP = const OID._internal("1.3.6.1.4.1.311.60.2.1.2");
static const jurisdictionOfIncorporationC = const OID._internal("1.3.6.1.4.1.311.60.2.1.3");
static const certificateExtension =
const OID._internal("1.3.6.1.4.1.11129.2.4.2");
static const jurisdictionOfIncorporationSP =
const OID._internal("1.3.6.1.4.1.311.60.2.1.2");
static const jurisdictionOfIncorporationC =
const OID._internal("1.3.6.1.4.1.311.60.2.1.3");
static const authorityInfoAccess = const OID._internal("1.3.6.1.5.5.7.1.1");
static const qcStatements = const OID._internal("1.3.6.1.5.5.7.1.3");
static const cps = const OID._internal("1.3.6.1.5.5.7.2.1");
......@@ -160,7 +172,8 @@ class OID {
static const sha384 = const OID._internal("2.16.840.1.101.3.4.2.2");
static const sha512 = const OID._internal("2.16.840.1.101.3.4.2.3");
static const md5 = const OID._internal("1.2.840.113549.2.5");
static const VeriSignEVpolicy = const OID._internal("2.16.840.1.113733.1.7.23.6");
static const VeriSignEVpolicy =
const OID._internal("2.16.840.1.113733.1.7.23.6");
static const extendedValidation = const OID._internal("2.23.140.1.1");
static const organizationValidated = const OID._internal("2.23.140.1.2.2");
static const subjectKeyIdentifier = const OID._internal("2.5.29.14");
......
......@@ -322,7 +322,11 @@ class X509Certificate {
///Gets the certificate constraints path length from the
///critical BasicConstraints extension, (OID = 2.5.29.19).
int get basicConstraints {
var sub = extensionObject(oid: OID.basicConstraints)?.block?.lastSub()?.lastSub()?.lastSub();
var sub = extensionObject(oid: OID.basicConstraints)
?.block
?.lastSub()
?.lastSub()
?.lastSub();
if (sub != null) {
if (sub.value is List<int>) {
return (sub.value as List<int>).length;
......@@ -333,31 +337,60 @@ class X509Certificate {
///Gets the raw bits from the Subject Key Identifier (SKID) extension, (OID = 2.5.29.14).
List<int> get subjectKeyIdentifier =>
extensionObject(oid: OID.subjectKeyIdentifier)?.block?.lastSub()?.lastSub()?.value ?? <int>[];
extensionObject(oid: OID.subjectKeyIdentifier)
?.block
?.lastSub()
?.lastSub()
?.value ??
<int>[];
///Gets the raw bits from the Authority Key Identifier extension, (OID = 2.5.29.35).
List<int> get authorityKeyIdentifier =>
extensionObject(oid: OID.authorityKeyIdentifier)?.block?.lastSub()?.lastSub()?.firstSub()?.value ?? <int>[];
extensionObject(oid: OID.authorityKeyIdentifier)
?.block
?.lastSub()
?.lastSub()
?.firstSub()
?.value ??
<int>[];
///Gets the list of certificate policies from the CertificatePolicies extension, (OID = 2.5.29.32).
List<String> get certificatePolicies =>
extensionObject(oid: OID.certificatePolicies)?.block?.lastSub()?.firstSub()?.sub?.map((e) => e.firstSub()?.value as String)?.toList() ?? <String>[];
extensionObject(oid: OID.certificatePolicies)
?.block
?.lastSub()
?.firstSub()
?.sub
?.map((e) => e.firstSub()?.value as String)
?.toList() ??
<String>[];
///Gets the list of CRL distribution points from the CRLDistributionPoints extension, (OID = 2.5.29.31).
List<String> get cRLDistributionPoints =>
extensionObject(oid: OID.cRLDistributionPoints)?.block?.lastSub()?.firstSub()?.sub?.map((e) => e.firstSub()?.firstSub()?.firstSub()?.value as String)?.toList() ?? <String>[];
extensionObject(oid: OID.cRLDistributionPoints)
?.block
?.lastSub()
?.firstSub()
?.sub
?.map((e) => e.firstSub()?.firstSub()?.firstSub()?.value as String)
?.toList() ??
<String>[];
///Gets the map of the format (as a key) and location (as a value) of additional information
///about the CA who issued the certificate in which this extension appears
///from the AuthorityInfoAccess extension, (OID = 1.3.6.1.5.5.5.7.1.1).
Map<String, String> get authorityInfoAccess {
var result = <String, String>{};
var sub = extensionObject(oid: OID.authorityInfoAccess)?.block?.lastSub()?.firstSub()?.sub;
var sub = extensionObject(oid: OID.authorityInfoAccess)
?.block
?.lastSub()
?.firstSub()
?.sub;
if (sub != null) {
sub.forEach((element) {
if (element.subCount() > 1) {
result.putIfAbsent(element.subAtIndex(0).value,
() => element.subAtIndex(1).value);
result.putIfAbsent(
element.subAtIndex(0).value, () => element.subAtIndex(1).value);
}
});
}
......@@ -413,8 +446,6 @@ class X509Certificate {
result += quote;
}
}
}
}
return result;
......
......@@ -52,4 +52,4 @@ class X509Extension {
}
return result;
}
}
\ No newline at end of file
}
......@@ -25,11 +25,13 @@ class X509PublicKey {
} else if (oid == OID.rsaEncryption) {
List<ASN1Object> publicKeyAsn1Objects;
try {
publicKeyAsn1Objects = ASN1DERDecoder.decode(data: keyData.toList(growable: true));
} catch(e) {}
publicKeyAsn1Objects =
ASN1DERDecoder.decode(data: keyData.toList(growable: true));
} catch (e) {}
if (publicKeyAsn1Objects != null && publicKeyAsn1Objects.length > 0) {
var publicKeyModulus = publicKeyAsn1Objects.first?.subAtIndex(0)?.value;
var publicKeyModulus =
publicKeyAsn1Objects.first?.subAtIndex(0)?.value;
if (publicKeyModulus != null) {
return Uint8List.fromList(publicKeyModulus);
}
......@@ -51,4 +53,4 @@ class X509PublicKey {
Map<String, dynamic> toJson() {
return toMap();
}
}
\ No newline at end of file
}
......@@ -84,7 +84,8 @@ class CookieManager {
expiresDate: cookieListMap[i]["expiresDate"],
isSessionOnly: cookieListMap[i]["isSessionOnly"],
domain: cookieListMap[i]["domain"],
sameSite: HTTPCookieSameSitePolicy.fromValue(cookieListMap[i]["sameSite"]),
sameSite:
HTTPCookieSameSitePolicy.fromValue(cookieListMap[i]["sameSite"]),
isSecure: cookieListMap[i]["isSecure"],
isHttpOnly: cookieListMap[i]["isHttpOnly"],
path: cookieListMap[i]["path"]));
......@@ -111,7 +112,8 @@ class CookieManager {
expiresDate: cookies[i]["expiresDate"],
isSessionOnly: cookies[i]["isSessionOnly"],
domain: cookies[i]["domain"],
sameSite: HTTPCookieSameSitePolicy.fromValue(cookies[i]["sameSite"]),
sameSite:
HTTPCookieSameSitePolicy.fromValue(cookies[i]["sameSite"]),
isSecure: cookies[i]["isSecure"],
isHttpOnly: cookies[i]["isHttpOnly"],
path: cookies[i]["path"]);
......
......@@ -31,7 +31,8 @@ class HttpAuthCredentialDatabase {
///Gets a map list of all HTTP auth credentials saved.
///Each map contains the key `protectionSpace` of type [ProtectionSpace]
///and the key `credentials` of type `List<HttpAuthCredential>` that contains all the HTTP auth credentials saved for that `protectionSpace`.
Future<List<ProtectionSpaceHttpAuthCredentials>> getAllAuthCredentials() async {
Future<List<ProtectionSpaceHttpAuthCredentials>>
getAllAuthCredentials() async {
Map<String, dynamic> args = <String, dynamic>{};
List<dynamic> allCredentials =
await _channel.invokeMethod('getAllAuthCredentials', args);
......@@ -41,20 +42,17 @@ class HttpAuthCredentialDatabase {
for (Map<dynamic, dynamic> map in allCredentials) {
Map<dynamic, dynamic> protectionSpace = map["protectionSpace"];
List<dynamic> credentials = map["credentials"];
result.add(
ProtectionSpaceHttpAuthCredentials(
protectionSpace: ProtectionSpace(
host: protectionSpace["host"],
protocol: protectionSpace["protocol"],
realm: protectionSpace["realm"],
port: protectionSpace["port"]),
credentials: credentials
.map((credential) => HttpAuthCredential(
result.add(ProtectionSpaceHttpAuthCredentials(
protectionSpace: ProtectionSpace(
host: protectionSpace["host"],
protocol: protectionSpace["protocol"],
realm: protectionSpace["realm"],
port: protectionSpace["port"]),
credentials: credentials
.map((credential) => HttpAuthCredential(
username: credential["username"],
password: credential["password"]))
.toList()
)
);
.toList()));
}
return result;
}
......
......@@ -291,7 +291,7 @@ class _InAppWebViewState extends State<InAppWebView> {
if (gestureRecognizers == null) {
gestureRecognizers = <Factory<OneSequenceGestureRecognizer>>[
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
() => EagerGestureRecognizer(),
),
].toSet();
}
......
......@@ -69,7 +69,8 @@ class InAppWebViewController {
this._webview = webview;
this.android = AndroidInAppWebViewController(this);
this.ios = IOSInAppWebViewController(this);
this.webStorage = WebStorage(localStorage: LocalStorage(this), sessionStorage: SessionStorage(this));
this.webStorage = WebStorage(
localStorage: LocalStorage(this), sessionStorage: SessionStorage(this));
}
InAppWebViewController.fromInAppBrowser(
......@@ -369,29 +370,45 @@ class InAppWebViewController {
int androidError = call.arguments["androidError"];
int iosError = call.arguments["iosError"];
String message = call.arguments["message"];
Map<String, dynamic> sslCertificateMap = call.arguments["sslCertificate"]?.cast<String, dynamic>();
Map<String, dynamic> sslCertificateMap =
call.arguments["sslCertificate"]?.cast<String, dynamic>();
SslCertificate sslCertificate;
if (sslCertificateMap != null) {
if (Platform.isIOS) {
try {
X509Certificate x509certificate = X509Certificate.fromData(data: sslCertificateMap["x509Certificate"]);
X509Certificate x509certificate = X509Certificate.fromData(
data: sslCertificateMap["x509Certificate"]);
sslCertificate = SslCertificate(
issuedBy: SslCertificateDName(
CName: x509certificate.issuer(dn: ASN1DistinguishedNames.COMMON_NAME) ?? "",
CName: x509certificate.issuer(
dn: ASN1DistinguishedNames.COMMON_NAME) ??
"",
DName: x509certificate.issuerDistinguishedName ?? "",
OName: x509certificate.issuer(dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? "",
UName: x509certificate.issuer(dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ?? ""),
OName: x509certificate.issuer(
dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ??
"",
UName: x509certificate.issuer(
dn: ASN1DistinguishedNames
.ORGANIZATIONAL_UNIT_NAME) ??
""),
issuedTo: SslCertificateDName(
CName: x509certificate.subject(dn: ASN1DistinguishedNames.COMMON_NAME) ?? "",
CName: x509certificate.subject(
dn: ASN1DistinguishedNames.COMMON_NAME) ??
"",
DName: x509certificate.subjectDistinguishedName ?? "",
OName: x509certificate.subject(dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? "",
UName: x509certificate.subject(dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ?? ""),
OName: x509certificate.subject(
dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ??
"",
UName: x509certificate.subject(
dn: ASN1DistinguishedNames
.ORGANIZATIONAL_UNIT_NAME) ??
""),
validNotAfterDate: x509certificate.notAfter,
validNotBeforeDate: x509certificate.notBefore,
x509Certificate: x509certificate,
);
} catch(e, stacktrace) {
} catch (e, stacktrace) {
print(e);
print(stacktrace);
return null;
......@@ -401,8 +418,11 @@ class InAppWebViewController {
}
}
AndroidSslError androidSslError = androidError != null ? AndroidSslError.fromValue(androidError) : null;
IOSSslError iosSslError = iosError != null ? IOSSslError.fromValue(iosError) : null;
AndroidSslError androidSslError = androidError != null
? AndroidSslError.fromValue(androidError)
: null;
IOSSslError iosSslError =
iosError != null ? IOSSslError.fromValue(iosError) : null;
var protectionSpace = ProtectionSpace(
host: host, protocol: protocol, realm: realm, port: port);
......@@ -884,8 +904,7 @@ class InAppWebViewController {
InAppWebViewGroupOptions options = await getOptions();
if (options != null && options.crossPlatform.javaScriptEnabled == true) {
List<Map<dynamic, dynamic>> links = (await evaluateJavascript(
source: """
List<Map<dynamic, dynamic>> links = (await evaluateJavascript(source: """
(function() {
var linkNodes = document.head.getElementsByTagName("link");
var links = [];
......@@ -920,8 +939,8 @@ class InAppWebViewController {
manifestUrl = manifestUrl.substring(1);
}
manifestUrl = ((assetPathBase == null)
? url.scheme + "://" + url.host + "/"
: assetPathBase) +
? url.scheme + "://" + url.host + "/"
: assetPathBase) +
manifestUrl;
}
continue;
......@@ -1466,7 +1485,8 @@ class InAppWebViewController {
///
///**Official Android API**: https://developer.android.com/reference/android/view/View#scrollTo(int,%20int)
///**Official iOS API**: https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset
Future<void> scrollTo({@required int x, @required int y, bool animated = false}) async {
Future<void> scrollTo(
{@required int x, @required int y, bool animated = false}) async {
assert(x != null && y != null);
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('x', () => x);
......@@ -1485,7 +1505,8 @@ class InAppWebViewController {
///
///**Official Android API**: https://developer.android.com/reference/android/view/View#scrollBy(int,%20int)
///**Official iOS API**: https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset
Future<void> scrollBy({@required int x, @required int y, bool animated = false}) async {
Future<void> scrollBy(
{@required int x, @required int y, bool animated = false}) async {
assert(x != null && y != null);
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('x', () => x);
......@@ -1544,7 +1565,8 @@ class InAppWebViewController {
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#zoomBy(float)
///**Official iOS API**: https://developer.apple.com/documentation/uikit/uiscrollview/1619412-setzoomscale
Future<void> zoomBy(double zoomFactor) async {
assert(!Platform.isAndroid || (Platform.isAndroid && zoomFactor > 0.01 && zoomFactor <= 100.0));
assert(!Platform.isAndroid ||
(Platform.isAndroid && zoomFactor > 0.01 && zoomFactor <= 100.0));
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('zoomFactor', () => zoomFactor);
......@@ -1611,12 +1633,15 @@ class InAppWebViewController {
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#requestFocusNodeHref(android.os.Message)
Future<RequestFocusNodeHrefResult> requestFocusNodeHref() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<dynamic, dynamic> result = await _channel.invokeMethod('requestFocusNodeHref', args);
return result != null ? RequestFocusNodeHrefResult(
url: result['url'],
title: result['title'],
src: result['src'],
) : null;
Map<dynamic, dynamic> result =
await _channel.invokeMethod('requestFocusNodeHref', args);
return result != null
? RequestFocusNodeHrefResult(
url: result['url'],
title: result['title'],
src: result['src'],
)
: null;
}
///Requests the URL of the image last touched by the user.
......@@ -1626,10 +1651,13 @@ class InAppWebViewController {
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#requestImageRef(android.os.Message)
Future<RequestImageRefResult> requestImageRef() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<dynamic, dynamic> result = await _channel.invokeMethod('requestImageRef', args);
return result != null ? RequestImageRefResult(
url: result['url'],
) : null;
Map<dynamic, dynamic> result =
await _channel.invokeMethod('requestImageRef', args);
return result != null
? RequestImageRefResult(
url: result['url'],
)
: null;
}
///Returns the list of `<meta>` tags of the current WebView.
......@@ -1638,7 +1666,8 @@ class InAppWebViewController {
Future<List<MetaTag>> getMetaTags() async {
List<MetaTag> metaTags = [];
List<Map<dynamic, dynamic>> metaTagList = (await evaluateJavascript(source: """
List<Map<dynamic, dynamic>> metaTagList =
(await evaluateJavascript(source: """
(function() {
var metaTags = [];
var metaTagNodes = document.head.getElementsByTagName('meta');
......@@ -1682,14 +1711,12 @@ class InAppWebViewController {
var attrs = <MetaTagAttribute>[];
for (var metaTagAttr in metaTag["attrs"]) {
attrs.add(
MetaTagAttribute(name: metaTagAttr["name"], value: metaTagAttr["value"])
);
attrs.add(MetaTagAttribute(
name: metaTagAttr["name"], value: metaTagAttr["value"]));
}
metaTags.add(
MetaTag(name: metaTag["name"], content: metaTag["content"], attrs: attrs)
);
metaTags.add(MetaTag(
name: metaTag["name"], content: metaTag["content"], attrs: attrs));
}
return metaTags;
......@@ -1743,28 +1770,43 @@ class InAppWebViewController {
Future<SslCertificate> getCertificate() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic> sslCertificateMap = (await _channel.invokeMethod('getCertificate', args))?.cast<String, dynamic>();
Map<String, dynamic> sslCertificateMap =
(await _channel.invokeMethod('getCertificate', args))
?.cast<String, dynamic>();
if (sslCertificateMap != null) {
if (Platform.isIOS) {
try {
X509Certificate x509certificate = X509Certificate.fromData(data: sslCertificateMap["x509Certificate"]);
X509Certificate x509certificate = X509Certificate.fromData(
data: sslCertificateMap["x509Certificate"]);
return SslCertificate(
issuedBy: SslCertificateDName(
CName: x509certificate.issuer(dn: ASN1DistinguishedNames.COMMON_NAME) ?? "",
CName: x509certificate.issuer(
dn: ASN1DistinguishedNames.COMMON_NAME) ??
"",
DName: x509certificate.issuerDistinguishedName ?? "",
OName: x509certificate.issuer(dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? "",
UName: x509certificate.issuer(dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ?? ""),
OName: x509certificate.issuer(
dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ??
"",
UName: x509certificate.issuer(
dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ??
""),
issuedTo: SslCertificateDName(
CName: x509certificate.subject(dn: ASN1DistinguishedNames.COMMON_NAME) ?? "",
CName: x509certificate.subject(
dn: ASN1DistinguishedNames.COMMON_NAME) ??
"",
DName: x509certificate.subjectDistinguishedName ?? "",
OName: x509certificate.subject(dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? "",
UName: x509certificate.subject(dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ?? ""),
OName: x509certificate.subject(
dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ??
"",
UName: x509certificate.subject(
dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ??
""),
validNotAfterDate: x509certificate.notAfter,
validNotBeforeDate: x509certificate.notBefore,
x509Certificate: x509certificate,
);
} catch(e, stacktrace) {
} catch (e, stacktrace) {
print(e);
print(stacktrace);
return null;
......
......@@ -46,7 +46,9 @@ class ConsoleMessageLevel {
static ConsoleMessageLevel fromValue(int value) {
if (value != null)
return ConsoleMessageLevel.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return ConsoleMessageLevel.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -134,11 +136,12 @@ class InAppWebViewInitialData {
///The URL to use as the history entry. The default value is `about:blank`. If non-null, this must be a valid URL. This parameter is used only on Android.
String historyUrl;
InAppWebViewInitialData({@required this.data,
this.mimeType = "text/html",
this.encoding = "utf8",
this.baseUrl = "about:blank",
this.historyUrl = "about:blank"});
InAppWebViewInitialData(
{@required this.data,
this.mimeType = "text/html",
this.encoding = "utf8",
this.baseUrl = "about:blank",
this.historyUrl = "about:blank"});
Map<String, String> toMap() {
return {
......@@ -196,12 +199,13 @@ class WebResourceRequest {
///**NOTE**: Available on Android 21+. For Android < 21 it will be always `false`.
bool isRedirect;
WebResourceRequest({@required this.url,
this.headers,
this.method,
this.hasGesture,
this.isForMainFrame,
this.isRedirect});
WebResourceRequest(
{@required this.url,
this.headers,
this.method,
this.hasGesture,
this.isForMainFrame,
this.isRedirect});
Map<String, dynamic> toMap() {
return {
......@@ -255,12 +259,13 @@ class WebResourceResponse {
///**NOTE**: Available on Android 21+. For Android < 21 it won't be used.
String reasonPhrase;
WebResourceResponse({this.contentType = "",
this.contentEncoding = "utf-8",
this.data,
this.headers,
this.statusCode,
this.reasonPhrase});
WebResourceResponse(
{this.contentType = "",
this.contentEncoding = "utf-8",
this.data,
this.headers,
this.statusCode,
this.reasonPhrase});
Map<String, dynamic> toMap() {
return {
......@@ -294,9 +299,10 @@ class CustomSchemeResponse {
///Content-Enconding of the data, such as `utf-8`.
String contentEnconding;
CustomSchemeResponse({@required this.data,
@required this.contentType,
this.contentEnconding = 'utf-8'});
CustomSchemeResponse(
{@required this.data,
@required this.contentType,
this.contentEnconding = 'utf-8'});
Map<String, dynamic> toMap() {
return {
......@@ -463,10 +469,11 @@ class JsAlertResponse {
///Action used to confirm that the user hit confirm button.
JsAlertResponseAction action;
JsAlertResponse({this.message = "",
this.handledByClient = false,
this.confirmButtonTitle = "",
this.action = JsAlertResponseAction.CONFIRM});
JsAlertResponse(
{this.message = "",
this.handledByClient = false,
this.confirmButtonTitle = "",
this.action = JsAlertResponseAction.CONFIRM});
Map<String, dynamic> toMap() {
return {
......@@ -521,11 +528,12 @@ class JsConfirmResponse {
///Action used to confirm that the user hit confirm or cancel button.
JsConfirmResponseAction action;
JsConfirmResponse({this.message = "",
this.handledByClient = false,
this.confirmButtonTitle = "",
this.cancelButtonTitle = "",
this.action = JsConfirmResponseAction.CANCEL});
JsConfirmResponse(
{this.message = "",
this.handledByClient = false,
this.confirmButtonTitle = "",
this.cancelButtonTitle = "",
this.action = JsConfirmResponseAction.CANCEL});
Map<String, dynamic> toMap() {
return {
......@@ -587,13 +595,14 @@ class JsPromptResponse {
///Action used to confirm that the user hit confirm or cancel button.
JsPromptResponseAction action;
JsPromptResponse({this.message = "",
this.defaultValue = "",
this.handledByClient = false,
this.confirmButtonTitle = "",
this.cancelButtonTitle = "",
this.value,
this.action = JsPromptResponseAction.CANCEL});
JsPromptResponse(
{this.message = "",
this.defaultValue = "",
this.handledByClient = false,
this.confirmButtonTitle = "",
this.cancelButtonTitle = "",
this.value,
this.action = JsPromptResponseAction.CANCEL});
Map<String, dynamic> toMap() {
return {
......@@ -633,7 +642,9 @@ class SafeBrowsingThreat {
static SafeBrowsingThreat fromValue(int value) {
if (value != null)
return SafeBrowsingThreat.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return SafeBrowsingThreat.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -656,15 +667,15 @@ class SafeBrowsingThreat {
}
static const SAFE_BROWSING_THREAT_UNKNOWN =
const SafeBrowsingThreat._internal(0);
const SafeBrowsingThreat._internal(0);
static const SAFE_BROWSING_THREAT_MALWARE =
const SafeBrowsingThreat._internal(1);
const SafeBrowsingThreat._internal(1);
static const SAFE_BROWSING_THREAT_PHISHING =
const SafeBrowsingThreat._internal(2);
const SafeBrowsingThreat._internal(2);
static const SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE =
const SafeBrowsingThreat._internal(3);
const SafeBrowsingThreat._internal(3);
static const SAFE_BROWSING_THREAT_BILLING =
const SafeBrowsingThreat._internal(4);
const SafeBrowsingThreat._internal(4);
bool operator ==(value) => value == _value;
......@@ -688,7 +699,7 @@ class SafeBrowsingResponseAction {
///Display the default interstitial.
static const SHOW_INTERSTITIAL =
const SafeBrowsingResponseAction._internal(2);
const SafeBrowsingResponseAction._internal(2);
bool operator ==(value) => value == _value;
......@@ -705,8 +716,9 @@ class SafeBrowsingResponse {
///Indicate the [SafeBrowsingResponseAction] to take when hitting a malicious URL.
SafeBrowsingResponseAction action;
SafeBrowsingResponse({this.report = true,
this.action = SafeBrowsingResponseAction.SHOW_INTERSTITIAL});
SafeBrowsingResponse(
{this.report = true,
this.action = SafeBrowsingResponseAction.SHOW_INTERSTITIAL});
Map<String, dynamic> toMap() {
return {"report": report, "action": action?.toValue()};
......@@ -738,7 +750,7 @@ class HttpAuthResponseAction {
///Uses the credentials stored for the current host.
static const USE_SAVED_HTTP_AUTH_CREDENTIALS =
const HttpAuthResponseAction._internal(2);
const HttpAuthResponseAction._internal(2);
bool operator ==(value) => value == _value;
......@@ -760,10 +772,11 @@ class HttpAuthResponse {
///Indicate the [HttpAuthResponseAction] to take in response of the authentication challenge.
HttpAuthResponseAction action;
HttpAuthResponse({this.username = "",
this.password = "",
this.permanentPersistence = false,
this.action = HttpAuthResponseAction.CANCEL});
HttpAuthResponse(
{this.username = "",
this.password = "",
this.permanentPersistence = false,
this.action = HttpAuthResponseAction.CANCEL});
Map<String, dynamic> toMap() {
return {
......@@ -888,7 +901,8 @@ class ProtectionSpaceHttpAuthCredentials {
Map<String, dynamic> toMap() {
return {
"protectionSpace": protectionSpace?.toMap(),
"credentials": credentials?.map((credential) => credential?.toMap())?.toList()
"credentials":
credentials?.map((credential) => credential?.toMap())?.toList()
};
}
......@@ -963,11 +977,12 @@ class ServerTrustChallenge {
///The SSL certificate used for this challenge.
SslCertificate sslCertificate;
ServerTrustChallenge({@required this.protectionSpace,
this.androidError,
this.iosError,
this.message,
this.sslCertificate})
ServerTrustChallenge(
{@required this.protectionSpace,
this.androidError,
this.iosError,
this.message,
this.sslCertificate})
: assert(protectionSpace != null);
Map<String, dynamic> toMap() {
......@@ -1027,10 +1042,11 @@ class ClientCertResponse {
///Indicate the [ClientCertResponseAction] to take in response of the client certificate challenge.
ClientCertResponseAction action;
ClientCertResponse({this.certificatePath,
this.certificatePassword = "",
this.androidKeyStoreType = "PKCS12",
this.action = ClientCertResponseAction.CANCEL}) {
ClientCertResponse(
{this.certificatePath,
this.certificatePassword = "",
this.androidKeyStoreType = "PKCS12",
this.action = ClientCertResponseAction.CANCEL}) {
if (this.action == ClientCertResponseAction.PROCEED)
assert(certificatePath != null && certificatePath.isNotEmpty);
}
......@@ -1123,7 +1139,9 @@ class AndroidCacheMode {
static AndroidCacheMode fromValue(int value) {
if (value != null)
return AndroidCacheMode.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AndroidCacheMode.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1180,7 +1198,9 @@ class AndroidActionModeMenuItem {
static AndroidActionModeMenuItem fromValue(int value) {
if (value != null)
return AndroidActionModeMenuItem.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AndroidActionModeMenuItem.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1209,11 +1229,11 @@ class AndroidActionModeMenuItem {
///Disable menu item "Web Search".
static const MENU_ITEM_WEB_SEARCH =
const AndroidActionModeMenuItem._internal(2);
const AndroidActionModeMenuItem._internal(2);
///Disable all the action mode menu items for text processing.
static const MENU_ITEM_PROCESS_TEXT =
const AndroidActionModeMenuItem._internal(4);
const AndroidActionModeMenuItem._internal(4);
bool operator ==(value) => value == _value;
......@@ -1237,7 +1257,9 @@ class AndroidForceDark {
static AndroidForceDark fromValue(int value) {
if (value != null)
return AndroidForceDark.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AndroidForceDark.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1286,7 +1308,9 @@ class AndroidLayoutAlgorithm {
static AndroidLayoutAlgorithm fromValue(String value) {
if (value != null)
return AndroidLayoutAlgorithm.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AndroidLayoutAlgorithm.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1303,11 +1327,11 @@ class AndroidLayoutAlgorithm {
///
///**NOTE**: available on Android 19+.
static const TEXT_AUTOSIZING =
const AndroidLayoutAlgorithm._internal("TEXT_AUTOSIZING");
const AndroidLayoutAlgorithm._internal("TEXT_AUTOSIZING");
///NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use this for API levels prior to `Build.VERSION_CODES.KITKAT`.
static const NARROW_COLUMNS =
const AndroidLayoutAlgorithm._internal("NARROW_COLUMNS");
const AndroidLayoutAlgorithm._internal("NARROW_COLUMNS");
bool operator ==(value) => value == _value;
......@@ -1331,7 +1355,9 @@ class AndroidMixedContentMode {
static AndroidMixedContentMode fromValue(int value) {
if (value != null)
return AndroidMixedContentMode.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AndroidMixedContentMode.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1353,12 +1379,12 @@ class AndroidMixedContentMode {
///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure.
///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode.
static const MIXED_CONTENT_ALWAYS_ALLOW =
const AndroidMixedContentMode._internal(0);
const AndroidMixedContentMode._internal(0);
///In this mode, the WebView will not allow a secure origin to load content from an insecure origin.
///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode.
static const MIXED_CONTENT_NEVER_ALLOW =
const AndroidMixedContentMode._internal(1);
const AndroidMixedContentMode._internal(1);
///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content.
///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked.
......@@ -1366,7 +1392,7 @@ class AndroidMixedContentMode {
///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment.
///For highest security, apps are recommended to use [AndroidMixedContentMode.MIXED_CONTENT_NEVER_ALLOW].
static const MIXED_CONTENT_COMPATIBILITY_MODE =
const AndroidMixedContentMode._internal(2);
const AndroidMixedContentMode._internal(2);
bool operator ==(value) => value == _value;
......@@ -1387,7 +1413,9 @@ class IOSWKSelectionGranularity {
static IOSWKSelectionGranularity fromValue(int value) {
if (value != null)
return IOSWKSelectionGranularity.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSWKSelectionGranularity.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1439,7 +1467,9 @@ class IOSWKDataDetectorTypes {
static IOSWKDataDetectorTypes fromValue(String value) {
if (value != null)
return IOSWKDataDetectorTypes.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSWKDataDetectorTypes.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1453,7 +1483,7 @@ class IOSWKDataDetectorTypes {
///Phone numbers are detected and turned into links.
static const PHONE_NUMBER =
const IOSWKDataDetectorTypes._internal("PHONE_NUMBER");
const IOSWKDataDetectorTypes._internal("PHONE_NUMBER");
///URLs in text are detected and turned into links.
static const LINK = const IOSWKDataDetectorTypes._internal("LINK");
......@@ -1463,23 +1493,23 @@ class IOSWKDataDetectorTypes {
///Dates and times that are in the future are detected and turned into links.
static const CALENDAR_EVENT =
const IOSWKDataDetectorTypes._internal("CALENDAR_EVENT");
const IOSWKDataDetectorTypes._internal("CALENDAR_EVENT");
///Tracking numbers are detected and turned into links.
static const TRACKING_NUMBER =
const IOSWKDataDetectorTypes._internal("TRACKING_NUMBER");
const IOSWKDataDetectorTypes._internal("TRACKING_NUMBER");
///Flight numbers are detected and turned into links.
static const FLIGHT_NUMBER =
const IOSWKDataDetectorTypes._internal("FLIGHT_NUMBER");
const IOSWKDataDetectorTypes._internal("FLIGHT_NUMBER");
///Lookup suggestions are detected and turned into links.
static const LOOKUP_SUGGESTION =
const IOSWKDataDetectorTypes._internal("LOOKUP_SUGGESTION");
const IOSWKDataDetectorTypes._internal("LOOKUP_SUGGESTION");
///Spotlight suggestions are detected and turned into links.
static const SPOTLIGHT_SUGGESTION =
const IOSWKDataDetectorTypes._internal("SPOTLIGHT_SUGGESTION");
const IOSWKDataDetectorTypes._internal("SPOTLIGHT_SUGGESTION");
///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added.
static const ALL = const IOSWKDataDetectorTypes._internal("ALL");
......@@ -1503,7 +1533,9 @@ class IOSUIScrollViewDecelerationRate {
static IOSUIScrollViewDecelerationRate fromValue(String value) {
if (value != null)
return IOSUIScrollViewDecelerationRate.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSUIScrollViewDecelerationRate.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1514,7 +1546,7 @@ class IOSUIScrollViewDecelerationRate {
///The default deceleration rate for a scroll view: `0.998`.
static const NORMAL =
const IOSUIScrollViewDecelerationRate._internal("NORMAL");
const IOSUIScrollViewDecelerationRate._internal("NORMAL");
///A fast deceleration rate for a scroll view: `0.99`.
static const FAST = const IOSUIScrollViewDecelerationRate._internal("FAST");
......@@ -1539,7 +1571,9 @@ class UserPreferredContentMode {
static UserPreferredContentMode fromValue(int value) {
if (value != null)
return UserPreferredContentMode.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return UserPreferredContentMode.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1594,7 +1628,9 @@ class IOSUIModalPresentationStyle {
static IOSUIModalPresentationStyle fromValue(int value) {
if (value != null)
return IOSUIModalPresentationStyle.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSUIModalPresentationStyle.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1644,11 +1680,11 @@ class IOSUIModalPresentationStyle {
///A view presentation style in which the presented view covers the screen.
static const OVER_FULL_SCREEN =
const IOSUIModalPresentationStyle._internal(5);
const IOSUIModalPresentationStyle._internal(5);
///A presentation style where the content is displayed over another view controller’s content.
static const OVER_CURRENT_CONTEXT =
const IOSUIModalPresentationStyle._internal(6);
const IOSUIModalPresentationStyle._internal(6);
///A presentation style where the content is displayed in a popover view.
static const POPOVER = const IOSUIModalPresentationStyle._internal(7);
......@@ -1682,7 +1718,9 @@ class IOSUIModalTransitionStyle {
static IOSUIModalTransitionStyle fromValue(int value) {
if (value != null)
return IOSUIModalTransitionStyle.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSUIModalTransitionStyle.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1743,7 +1781,9 @@ class IOSSafariDismissButtonStyle {
static IOSSafariDismissButtonStyle fromValue(int value) {
if (value != null)
return IOSSafariDismissButtonStyle.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSSafariDismissButtonStyle.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -1788,9 +1828,7 @@ class InAppWebViewGroupOptions {
///iOS-specific options.
IOSInAppWebViewOptions ios;
InAppWebViewGroupOptions({this.crossPlatform,
this.android,
this.ios}) {
InAppWebViewGroupOptions({this.crossPlatform, this.android, this.ios}) {
this.crossPlatform = this.crossPlatform ?? InAppWebViewOptions();
this.android = this.android ?? AndroidInAppWebViewOptions();
this.ios = this.ios ?? IOSInAppWebViewOptions();
......@@ -1807,7 +1845,8 @@ class InAppWebViewGroupOptions {
}
static InAppWebViewGroupOptions fromMap(Map<String, dynamic> options) {
InAppWebViewGroupOptions inAppWebViewGroupOptions = InAppWebViewGroupOptions();
InAppWebViewGroupOptions inAppWebViewGroupOptions =
InAppWebViewGroupOptions();
inAppWebViewGroupOptions.crossPlatform =
InAppWebViewOptions.fromMap(options);
......@@ -1848,10 +1887,11 @@ class InAppBrowserClassOptions {
///WebView options.
InAppWebViewGroupOptions inAppWebViewGroupOptions;
InAppBrowserClassOptions({this.crossPlatform,
this.android,
this.ios,
this.inAppWebViewGroupOptions}) {
InAppBrowserClassOptions(
{this.crossPlatform,
this.android,
this.ios,
this.inAppWebViewGroupOptions}) {
this.crossPlatform = this.crossPlatform ?? InAppBrowserOptions();
this.android = this.android ?? AndroidInAppBrowserOptions();
this.ios = this.ios ?? IOSInAppBrowserOptions();
......@@ -1885,7 +1925,8 @@ class InAppBrowserClassOptions {
}
static InAppBrowserClassOptions fromMap(Map<String, dynamic> options) {
InAppBrowserClassOptions inAppBrowserClassOptions = InAppBrowserClassOptions();
InAppBrowserClassOptions inAppBrowserClassOptions =
InAppBrowserClassOptions();
inAppBrowserClassOptions.crossPlatform =
InAppBrowserOptions.fromMap(options);
......@@ -1920,10 +1961,7 @@ class ChromeSafariBrowserClassOptions {
///iOS-specific options.
IOSSafariOptions ios;
ChromeSafariBrowserClassOptions({
this.android,
this.ios
}) {
ChromeSafariBrowserClassOptions({this.android, this.ios}) {
this.android = this.android ?? AndroidChromeCustomTabsOptions();
this.ios = this.ios ?? IOSSafariOptions();
}
......@@ -2000,7 +2038,9 @@ class AjaxRequestEventType {
static AjaxRequestEventType fromValue(String value) {
if (value != null)
return AjaxRequestEventType.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AjaxRequestEventType.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -2073,7 +2113,9 @@ class AjaxRequestReadyState {
static AjaxRequestReadyState fromValue(int value) {
if (value != null)
return AjaxRequestReadyState.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AjaxRequestReadyState.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -2211,25 +2253,26 @@ class AjaxRequest {
///Indicates the [AjaxRequestAction] that can be used to control the `XMLHttpRequest` request.
AjaxRequestAction action;
AjaxRequest({this.data,
this.method,
this.url,
this.isAsync,
this.user,
this.password,
this.withCredentials,
this.headers,
this.readyState,
this.status,
this.responseURL,
this.responseType,
this.response,
this.responseText,
this.responseXML,
this.statusText,
this.responseHeaders,
this.event,
this.action = AjaxRequestAction.PROCEED});
AjaxRequest(
{this.data,
this.method,
this.url,
this.isAsync,
this.user,
this.password,
this.withCredentials,
this.headers,
this.readyState,
this.status,
this.responseURL,
this.responseType,
this.response,
this.responseText,
this.responseXML,
this.statusText,
this.responseHeaders,
this.event,
this.action = AjaxRequestAction.PROCEED});
Map<String, dynamic> toMap() {
return {
......@@ -2450,19 +2493,20 @@ class FetchRequest {
///Indicates the [FetchRequestAction] that can be used to control the request.
FetchRequestAction action;
FetchRequest({this.url,
this.method,
this.headers,
this.body,
this.mode,
this.credentials,
this.cache,
this.redirect,
this.referrer,
this.referrerPolicy,
this.integrity,
this.keepalive,
this.action = FetchRequestAction.PROCEED});
FetchRequest(
{this.url,
this.method,
this.headers,
this.body,
this.mode,
this.credentials,
this.cache,
this.redirect,
this.referrer,
this.referrerPolicy,
this.integrity,
this.keepalive,
this.action = FetchRequestAction.PROCEED});
Map<String, dynamic> toMap() {
return {
......@@ -2536,7 +2580,9 @@ class ContentBlockerTriggerResourceType {
static ContentBlockerTriggerResourceType fromValue(String value) {
if (value != null)
return ContentBlockerTriggerResourceType.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return ContentBlockerTriggerResourceType.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -2546,18 +2592,18 @@ class ContentBlockerTriggerResourceType {
String toString() => _value;
static const DOCUMENT =
const ContentBlockerTriggerResourceType._internal('document');
const ContentBlockerTriggerResourceType._internal('document');
static const IMAGE =
const ContentBlockerTriggerResourceType._internal('image');
const ContentBlockerTriggerResourceType._internal('image');
static const STYLE_SHEET =
const ContentBlockerTriggerResourceType._internal('style-sheet');
const ContentBlockerTriggerResourceType._internal('style-sheet');
static const SCRIPT =
const ContentBlockerTriggerResourceType._internal('script');
const ContentBlockerTriggerResourceType._internal('script');
static const FONT = const ContentBlockerTriggerResourceType._internal('font');
static const MEDIA =
const ContentBlockerTriggerResourceType._internal('media');
const ContentBlockerTriggerResourceType._internal('media');
static const SVG_DOCUMENT =
const ContentBlockerTriggerResourceType._internal('svg-document');
const ContentBlockerTriggerResourceType._internal('svg-document');
///Any untyped load
static const RAW = const ContentBlockerTriggerResourceType._internal('raw');
......@@ -2581,7 +2627,9 @@ class ContentBlockerTriggerLoadType {
static ContentBlockerTriggerLoadType fromValue(String value) {
if (value != null)
return ContentBlockerTriggerLoadType.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return ContentBlockerTriggerLoadType.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -2592,11 +2640,11 @@ class ContentBlockerTriggerLoadType {
///FIRST_PARTY is triggered only if the resource has the same scheme, domain, and port as the main page resource.
static const FIRST_PARTY =
const ContentBlockerTriggerLoadType._internal('first-party');
const ContentBlockerTriggerLoadType._internal('first-party');
///THIRD_PARTY is triggered if the resource is not from the same domain as the main page resource.
static const THIRD_PARTY =
const ContentBlockerTriggerLoadType._internal('third-party');
const ContentBlockerTriggerLoadType._internal('third-party');
bool operator ==(value) => value == _value;
......@@ -2618,7 +2666,9 @@ class ContentBlockerActionType {
static ContentBlockerActionType fromValue(String value) {
if (value != null)
return ContentBlockerActionType.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return ContentBlockerActionType.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -2634,11 +2684,11 @@ class ContentBlockerActionType {
///
///**NOTE**: on Android, JavaScript must be enabled.
static const CSS_DISPLAY_NONE =
const ContentBlockerActionType._internal('css-display-none');
const ContentBlockerActionType._internal('css-display-none');
///Changes a URL from http to https. URLs with a specified (nondefault) port and links using other protocols are unaffected.
static const MAKE_HTTPS =
const ContentBlockerActionType._internal('make-https');
const ContentBlockerActionType._internal('make-https');
bool operator ==(value) => value == _value;
......@@ -2689,15 +2739,16 @@ class Cookie {
///**NOTE**: on Android it will be always `null`.
String path;
Cookie({@required this.name,
@required this.value,
this.expiresDate,
this.isSessionOnly,
this.domain,
this.sameSite,
this.isSecure,
this.isHttpOnly,
this.path});
Cookie(
{@required this.name,
@required this.value,
this.expiresDate,
this.isSessionOnly,
this.domain,
this.sameSite,
this.isSecure,
this.isHttpOnly,
this.path});
Map<String, dynamic> toMap() {
return {
......@@ -2751,8 +2802,9 @@ class PermissionRequestResponse {
///Indicate the [PermissionRequestResponseAction] to take in response of a permission request.
PermissionRequestResponseAction action;
PermissionRequestResponse({this.resources = const [],
this.action = PermissionRequestResponseAction.DENY});
PermissionRequestResponse(
{this.resources = const [],
this.action = PermissionRequestResponseAction.DENY});
Map<String, dynamic> toMap() {
return {"resources": resources, "action": action?.toValue()};
......@@ -2812,7 +2864,9 @@ class IOSWKNavigationType {
static IOSWKNavigationType fromValue(int value) {
if (value != null)
return IOSWKNavigationType.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSWKNavigationType.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -2870,13 +2924,14 @@ class ShouldOverrideUrlLoadingRequest {
///The type of action triggering the navigation. Available only on iOS.
IOSWKNavigationType iosWKNavigationType;
ShouldOverrideUrlLoadingRequest({this.url,
this.method,
this.headers,
this.isForMainFrame,
this.androidHasGesture,
this.androidIsRedirect,
this.iosWKNavigationType});
ShouldOverrideUrlLoadingRequest(
{this.url,
this.method,
this.headers,
this.isForMainFrame,
this.androidHasGesture,
this.androidIsRedirect,
this.iosWKNavigationType});
Map<String, dynamic> toMap() {
return {
......@@ -2914,10 +2969,11 @@ class OnCreateWindowRequest {
///The type of action triggering the navigation. Available only on iOS.
IOSWKNavigationType iosWKNavigationType;
OnCreateWindowRequest({this.url,
this.androidIsDialog,
this.androidIsUserGesture,
this.iosWKNavigationType});
OnCreateWindowRequest(
{this.url,
this.androidIsDialog,
this.androidIsUserGesture,
this.iosWKNavigationType});
Map<String, dynamic> toMap() {
return {
......@@ -2989,7 +3045,9 @@ class IOSWKWebsiteDataType {
static IOSWKWebsiteDataType fromValue(String value) {
if (value != null)
return IOSWKWebsiteDataType.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSWKWebsiteDataType.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3002,48 +3060,48 @@ class IOSWKWebsiteDataType {
///
///**NOTE**: available on iOS 11.3+.
static const WKWebsiteDataTypeFetchCache =
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeFetchCache");
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeFetchCache");
///On-disk caches.
static const WKWebsiteDataTypeDiskCache =
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeDiskCache");
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeDiskCache");
///In-memory caches.
static const WKWebsiteDataTypeMemoryCache =
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeMemoryCache");
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeMemoryCache");
///HTML offline web application caches.
static const WKWebsiteDataTypeOfflineWebApplicationCache =
const IOSWKWebsiteDataType._internal(
"WKWebsiteDataTypeOfflineWebApplicationCache");
const IOSWKWebsiteDataType._internal(
"WKWebsiteDataTypeOfflineWebApplicationCache");
///Cookies.
static const WKWebsiteDataTypeCookies =
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeCookies");
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeCookies");
///HTML session storage.
static const WKWebsiteDataTypeSessionStorage =
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeSessionStorage");
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeSessionStorage");
///HTML local storage.
static const WKWebsiteDataTypeLocalStorage =
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeLocalStorage");
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeLocalStorage");
///WebSQL databases.
static const WKWebsiteDataTypeWebSQLDatabases =
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeWebSQLDatabases");
const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeWebSQLDatabases");
///IndexedDB databases.
static const WKWebsiteDataTypeIndexedDBDatabases =
const IOSWKWebsiteDataType._internal(
"WKWebsiteDataTypeIndexedDBDatabases");
const IOSWKWebsiteDataType._internal(
"WKWebsiteDataTypeIndexedDBDatabases");
///Service worker registrations.
///
///**NOTE**: available on iOS 11.3+.
static const WKWebsiteDataTypeServiceWorkerRegistrations =
const IOSWKWebsiteDataType._internal(
"WKWebsiteDataTypeServiceWorkerRegistrations");
const IOSWKWebsiteDataType._internal(
"WKWebsiteDataTypeServiceWorkerRegistrations");
///Returns a set of all available website data types.
// ignore: non_constant_identifier_names
......@@ -3116,7 +3174,9 @@ class InAppWebViewHitTestResultType {
static InAppWebViewHitTestResultType fromValue(int value) {
if (value != null)
return InAppWebViewHitTestResultType.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return InAppWebViewHitTestResultType.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3162,15 +3222,15 @@ class InAppWebViewHitTestResultType {
///[InAppWebViewHitTestResult] for hitting a HTML::a tag with src=http.
static const SRC_ANCHOR_TYPE =
const InAppWebViewHitTestResultType._internal(7);
const InAppWebViewHitTestResultType._internal(7);
///[InAppWebViewHitTestResult] for hitting a HTML::a tag with src=http + HTML::img.
static const SRC_IMAGE_ANCHOR_TYPE =
const InAppWebViewHitTestResultType._internal(8);
const InAppWebViewHitTestResultType._internal(8);
///[InAppWebViewHitTestResult] for hitting an edit text area.
static const EDIT_TEXT_TYPE =
const InAppWebViewHitTestResultType._internal(9);
const InAppWebViewHitTestResultType._internal(9);
bool operator ==(value) => value == _value;
......@@ -3269,7 +3329,9 @@ class RendererPriority {
static RendererPriority fromValue(int value) {
if (value != null)
return RendererPriority.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return RendererPriority.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3297,7 +3359,7 @@ class RendererPriority {
///The renderer associated with this WebView is bound with Android `Context#BIND_IMPORTANT`.
static const RENDERER_PRIORITY_IMPORTANT =
const RendererPriority._internal(2);
const RendererPriority._internal(2);
bool operator ==(value) => value == _value;
......@@ -3318,8 +3380,9 @@ class RendererPriorityPolicy {
///If true, this flag specifies that when this WebView is not visible, it will be treated as if it had requested a priority of [RendererPriority.RENDERER_PRIORITY_WAIVED].
bool waivedWhenNotVisible;
RendererPriorityPolicy({@required this.rendererRequestedPriority,
@required this.waivedWhenNotVisible});
RendererPriorityPolicy(
{@required this.rendererRequestedPriority,
@required this.waivedWhenNotVisible});
Map<String, dynamic> toMap() {
return {
......@@ -3340,9 +3403,9 @@ class RendererPriorityPolicy {
static RendererPriorityPolicy fromMap(Map<String, dynamic> map) {
return map != null
? RendererPriorityPolicy(
rendererRequestedPriority:
RendererPriority.fromValue(map["rendererRequestedPriority"]),
waivedWhenNotVisible: map["waivedWhenNotVisible"])
rendererRequestedPriority:
RendererPriority.fromValue(map["rendererRequestedPriority"]),
waivedWhenNotVisible: map["waivedWhenNotVisible"])
: null;
}
}
......@@ -3395,7 +3458,9 @@ class AndroidOverScrollMode {
static AndroidOverScrollMode fromValue(int value) {
if (value != null)
return AndroidOverScrollMode.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AndroidOverScrollMode.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3419,7 +3484,7 @@ class AndroidOverScrollMode {
///Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll.
static const OVER_SCROLL_IF_CONTENT_SCROLLS =
const AndroidOverScrollMode._internal(1);
const AndroidOverScrollMode._internal(1);
///Never allow a user to over-scroll this view.
static const OVER_SCROLL_NEVER = const AndroidOverScrollMode._internal(2);
......@@ -3451,7 +3516,9 @@ class AndroidScrollBarStyle {
static AndroidScrollBarStyle fromValue(int value) {
if (value != null)
return AndroidScrollBarStyle.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AndroidScrollBarStyle.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3475,22 +3542,22 @@ class AndroidScrollBarStyle {
///The scrollbar style to display the scrollbars inside the content area, without increasing the padding.
///The scrollbars will be overlaid with translucency on the view's content.
static const SCROLLBARS_INSIDE_OVERLAY =
const AndroidScrollBarStyle._internal(0);
const AndroidScrollBarStyle._internal(0);
///The scrollbar style to display the scrollbars inside the padded area, increasing the padding of the view.
///The scrollbars will not overlap the content area of the view.
static const SCROLLBARS_INSIDE_INSET =
const AndroidScrollBarStyle._internal(16777216);
const AndroidScrollBarStyle._internal(16777216);
///The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding.
///The scrollbars will be overlaid with translucency.
static const SCROLLBARS_OUTSIDE_OVERLAY =
const AndroidScrollBarStyle._internal(33554432);
const AndroidScrollBarStyle._internal(33554432);
///The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view.
///The scrollbars will only overlap the background, if any.
static const SCROLLBARS_OUTSIDE_INSET =
const AndroidScrollBarStyle._internal(50331648);
const AndroidScrollBarStyle._internal(50331648);
bool operator ==(value) => value == _value;
......@@ -3512,7 +3579,9 @@ class AndroidVerticalScrollbarPosition {
static AndroidVerticalScrollbarPosition fromValue(int value) {
if (value != null)
return AndroidVerticalScrollbarPosition.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AndroidVerticalScrollbarPosition.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3533,15 +3602,15 @@ class AndroidVerticalScrollbarPosition {
///Position the scroll bar at the default position as determined by the system.
static const SCROLLBAR_POSITION_DEFAULT =
const AndroidVerticalScrollbarPosition._internal(0);
const AndroidVerticalScrollbarPosition._internal(0);
///Position the scroll bar along the left edge.
static const SCROLLBAR_POSITION_LEFT =
const AndroidVerticalScrollbarPosition._internal(1);
const AndroidVerticalScrollbarPosition._internal(1);
///Position the scroll bar along the right edge.
static const SCROLLBAR_POSITION_RIGHT =
const AndroidVerticalScrollbarPosition._internal(2);
const AndroidVerticalScrollbarPosition._internal(2);
bool operator ==(value) => value == _value;
......@@ -3562,7 +3631,7 @@ class AndroidWebViewPackageInfo {
static AndroidWebViewPackageInfo fromMap(Map<String, dynamic> map) {
return map != null
? AndroidWebViewPackageInfo(
versionName: map["versionName"], packageName: map["packageName"])
versionName: map["versionName"], packageName: map["packageName"])
: null;
}
......@@ -3698,7 +3767,9 @@ class WebStorageType {
static WebStorageType fromValue(String value) {
if (value != null)
return WebStorageType.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return WebStorageType.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3713,7 +3784,7 @@ class WebStorageType {
///`window.sessionStorage`: maintains a separate storage area for each given origin that's available for the duration
///of the page session (as long as the browser is open, including page reloads and restores).
static const SESSION_STORAGE =
const WebStorageType._internal("sessionStorage");
const WebStorageType._internal("sessionStorage");
bool operator ==(value) => value == _value;
......@@ -3735,7 +3806,9 @@ class HTTPCookieSameSitePolicy {
static HTTPCookieSameSitePolicy fromValue(String value) {
if (value != null)
return HTTPCookieSameSitePolicy.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return HTTPCookieSameSitePolicy.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3785,7 +3858,9 @@ class AndroidSslError {
static AndroidSslError fromValue(int value) {
if (value != null)
return AndroidSslError.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return AndroidSslError.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3852,7 +3927,9 @@ class IOSSslError {
static IOSSslError fromValue(int value) {
if (value != null)
return IOSSslError.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSSslError.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3918,7 +3995,9 @@ class IOSUIScrollViewContentInsetAdjustmentBehavior {
static IOSUIScrollViewContentInsetAdjustmentBehavior fromValue(int value) {
if (value != null)
return IOSUIScrollViewContentInsetAdjustmentBehavior.values.firstWhere((element) => element.toValue() == value, orElse: () => null);
return IOSUIScrollViewContentInsetAdjustmentBehavior.values.firstWhere(
(element) => element.toValue() == value,
orElse: () => null);
return null;
}
......@@ -3940,20 +4019,20 @@ class IOSUIScrollViewContentInsetAdjustmentBehavior {
}
///Automatically adjust the scroll view insets.
static const AUTOMATIC = const IOSUIScrollViewContentInsetAdjustmentBehavior
._internal(0);
static const AUTOMATIC =
const IOSUIScrollViewContentInsetAdjustmentBehavior._internal(0);
///Adjust the insets only in the scrollable directions.
static const SCROLLABLE_AXES = const IOSUIScrollViewContentInsetAdjustmentBehavior
._internal(1);
static const SCROLLABLE_AXES =
const IOSUIScrollViewContentInsetAdjustmentBehavior._internal(1);
///Do not adjust the scroll view insets.
static const NEVER = const IOSUIScrollViewContentInsetAdjustmentBehavior
._internal(2);
static const NEVER =
const IOSUIScrollViewContentInsetAdjustmentBehavior._internal(2);
///Always include the safe area insets in the content adjustment.
static const ALWAYS = const IOSUIScrollViewContentInsetAdjustmentBehavior
._internal(3);
static const ALWAYS =
const IOSUIScrollViewContentInsetAdjustmentBehavior._internal(3);
bool operator ==(value) => value == _value;
......@@ -3963,7 +4042,6 @@ class IOSUIScrollViewContentInsetAdjustmentBehavior {
///SSL certificate info (certificate details) class.
class SslCertificate {
///Name of the entity this certificate is issued by
SslCertificateDName issuedBy;
......@@ -3979,13 +4057,12 @@ class SslCertificate {
///The original source certificate, if available.
X509Certificate x509Certificate;
SslCertificate({
this.issuedBy,
this.issuedTo,
this.validNotAfterDate,
this.validNotBeforeDate,
this.x509Certificate
});
SslCertificate(
{this.issuedBy,
this.issuedTo,
this.validNotAfterDate,
this.validNotBeforeDate,
this.x509Certificate});
static SslCertificate fromMap(Map<String, dynamic> map) {
X509Certificate x509Certificate;
......@@ -3996,17 +4073,19 @@ class SslCertificate {
print(stacktrace);
}
return map != null ? SslCertificate(
issuedBy: SslCertificateDName.fromMap(
map["issuedBy"]?.cast<String, dynamic>()),
issuedTo: SslCertificateDName.fromMap(
map["issuedTo"]?.cast<String, dynamic>()),
validNotAfterDate: DateTime.fromMillisecondsSinceEpoch(
map["validNotAfterDate"]),
validNotBeforeDate: DateTime.fromMillisecondsSinceEpoch(
map["validNotBeforeDate"]),
x509Certificate: x509Certificate,
) : null;
return map != null
? SslCertificate(
issuedBy: SslCertificateDName.fromMap(
map["issuedBy"]?.cast<String, dynamic>()),
issuedTo: SslCertificateDName.fromMap(
map["issuedTo"]?.cast<String, dynamic>()),
validNotAfterDate:
DateTime.fromMillisecondsSinceEpoch(map["validNotAfterDate"]),
validNotBeforeDate:
DateTime.fromMillisecondsSinceEpoch(map["validNotBeforeDate"]),
x509Certificate: x509Certificate,
)
: null;
}
Map<String, dynamic> toMap() {
......@@ -4049,15 +4128,20 @@ class SslCertificateDName {
SslCertificateDName(
// ignore: non_constant_identifier_names
{this.CName = "", this.DName = "", this.OName = "", this.UName = ""});
{this.CName = "",
this.DName = "",
this.OName = "",
this.UName = ""});
static SslCertificateDName fromMap(Map<String, dynamic> map) {
return map != null ? SslCertificateDName(
CName: map["CName"] ?? "",
DName: map["DName"] ?? "",
OName: map["OName"] ?? "",
UName: map["UName"] ?? "",
) : null;
return map != null
? SslCertificateDName(
CName: map["CName"] ?? "",
DName: map["DName"] ?? "",
OName: map["OName"] ?? "",
UName: map["UName"] ?? "",
)
: null;
}
Map<String, dynamic> toMap() {
......
......@@ -15,7 +15,6 @@ class Util {
} else if (colorValue.startsWith("hlsa(")) {
return Util.getColorFromHlsaString(colorValue);
} else {
/**
This part of the code is generated using the JavaScript code below on this link: https://drafts.csswg.org/css-color/#typedef-color
......@@ -33,7 +32,7 @@ class Util {
code += '}';
*/
switch(colorValue) {
switch (colorValue) {
case "aliceblue":
return Util.getColorFromHex("#f0f8ff");
case "antiquewhite":
......@@ -337,8 +336,10 @@ class Util {
static Color getColorFromHex(String hexString) {
hexString = hexString.trim();
if (hexString.length == 4) { // convert for example #f00 to #ff0000
hexString = "#" + (hexString[1] * 2) + (hexString[2] * 2) + (hexString[3] * 2);
if (hexString.length == 4) {
// convert for example #f00 to #ff0000
hexString =
"#" + (hexString[1] * 2) + (hexString[2] * 2) + (hexString[3] * 2);
}
final buffer = StringBuffer();
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
......@@ -363,7 +364,8 @@ class Util {
.split(",")
.map((rbgValue) => rbgValue.trim())
.toList();
return Color.fromRGBO(int.parse(rgbaValues[0]), int.parse(rgbaValues[1]), int.parse(rgbaValues[2]), double.parse(rgbaValues[3]));
return Color.fromRGBO(int.parse(rgbaValues[0]), int.parse(rgbaValues[1]),
int.parse(rgbaValues[2]), double.parse(rgbaValues[3]));
}
static Color getColorFromHlsString(String hlsString) {
......@@ -385,10 +387,11 @@ class Util {
.map((rbgValue) => double.parse(rbgValue.trim()))
.toList();
var rgbaValues = hslToRgb(hlsaValues[0], hlsaValues[1], hlsaValues[2]);
return Color.fromRGBO(rgbaValues[0], rgbaValues[1], rgbaValues[2], hlsaValues[3]);
return Color.fromRGBO(
rgbaValues[0], rgbaValues[1], rgbaValues[2], hlsaValues[3]);
}
static List<num> hslToRgb(double h, double s, double l){
static List<num> hslToRgb(double h, double s, double l) {
double r, g, b;
if (s == 0) {
......@@ -396,30 +399,25 @@ class Util {
} else {
double q = l < 0.5 ? l * (1 + s) : l + s - l * s;
double p = 2 * l - q;
r = hueToRgb(p, q, h + 1/3);
r = hueToRgb(p, q, h + 1 / 3);
g = hueToRgb(p, q, h);
b = hueToRgb(p, q, h - 1/3);
b = hueToRgb(p, q, h - 1 / 3);
}
var rgb = [to255(r), to255(g), to255(b)];
return rgb;
}
static num to255(double v) {
return min(255, 256*v);
return min(255, 256 * v);
}
/// Helper method that converts hue to rgb
static double hueToRgb(double p, double q, double t) {
if (t < 0)
t += 1;
if (t > 1)
t -= 1;
if (t < 1/6)
return p + (q - p) * 6 * t;
if (t < 1/2)
return q;
if (t < 2/3)
return p + (q - p) * (2/3 - t) * 6;
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1 / 6) return p + (q - p) * 6 * t;
if (t < 1 / 2) return q;
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
return p;
}
}
\ No newline at end of file
}
......@@ -54,7 +54,7 @@ class Storage {
Future<void> setItem({@required String key, @required dynamic value}) async {
var encodedValue = json.encode(value);
await _controller.evaluateJavascript(source: """
window.$webStorageType.setItem("$key", ${ value is String ? encodedValue : "JSON.stringify($encodedValue)" });
window.$webStorageType.setItem("$key", ${value is String ? encodedValue : "JSON.stringify($encodedValue)"});
""");
}
......@@ -81,10 +81,10 @@ class Storage {
}
Future<List<WebStorageItem>> getItems() async {
var webStorageItems = <WebStorageItem>[];
List<Map<dynamic, dynamic>> items = (await _controller.evaluateJavascript(source: """
List<Map<dynamic, dynamic>> items =
(await _controller.evaluateJavascript(source: """
(function() {
var webStorageItems = [];
for(var i = 0; i < window.$webStorageType.length; i++){
......@@ -105,9 +105,8 @@ class Storage {
}
for (var item in items) {
webStorageItems.add(
WebStorageItem(key: item["key"], value: item["value"])
);
webStorageItems
.add(WebStorageItem(key: item["key"], value: item["value"]));
}
return webStorageItems;
......@@ -128,9 +127,11 @@ class Storage {
}
class LocalStorage extends Storage {
LocalStorage(InAppWebViewController controller) : super(controller, WebStorageType.LOCAL_STORAGE);
LocalStorage(InAppWebViewController controller)
: super(controller, WebStorageType.LOCAL_STORAGE);
}
class SessionStorage extends Storage {
SessionStorage(InAppWebViewController controller) : super(controller, WebStorageType.SESSION_STORAGE);
SessionStorage(InAppWebViewController controller)
: super(controller, WebStorageType.SESSION_STORAGE);
}
......@@ -838,7 +838,8 @@ class IOSInAppWebViewOptions
this.isPagingEnabled = false,
this.maximumZoomScale = 1.0,
this.minimumZoomScale = 1.0,
this.contentInsetAdjustmentBehavior = IOSUIScrollViewContentInsetAdjustmentBehavior.NEVER});
this.contentInsetAdjustmentBehavior =
IOSUIScrollViewContentInsetAdjustmentBehavior.NEVER});
@override
Map<String, dynamic> toMap() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment