();
if (cookies[i]["name"] == name)
- return cookies[i];
+ return Cookie(name: cookies[i]["name"], value: cookies[i]["value"]);
}
return null;
}
diff --git a/lib/src/types.dart b/lib/src/types.dart
index e5ef5308..e4e2e40b 100644
--- a/lib/src/types.dart
+++ b/lib/src/types.dart
@@ -1499,4 +1499,91 @@ class FetchRequest {
}
return null;
}
+}
+
+///ContentBlockerTriggerResourceType class represents the possible resource type defined for a [ContentBlockerTrigger].
+class ContentBlockerTriggerResourceType {
+ final String _value;
+ const ContentBlockerTriggerResourceType._internal(this._value);
+ static ContentBlockerTriggerResourceType fromValue(String value) {
+ return (["document", "image", "style-sheet", "script", "font",
+ "media", "svg-document", "raw"].contains(value)) ? ContentBlockerTriggerResourceType._internal(value) : null;
+ }
+ String toValue() => _value;
+ @override
+ String toString() => _value;
+
+ static const DOCUMENT = const ContentBlockerTriggerResourceType._internal('document');
+ static const IMAGE = const ContentBlockerTriggerResourceType._internal('image');
+ static const STYLE_SHEET = const ContentBlockerTriggerResourceType._internal('style-sheet');
+ static const SCRIPT = const ContentBlockerTriggerResourceType._internal('script');
+ static const FONT = const ContentBlockerTriggerResourceType._internal('font');
+ static const MEDIA = const ContentBlockerTriggerResourceType._internal('media');
+ static const SVG_DOCUMENT = const ContentBlockerTriggerResourceType._internal('svg-document');
+ ///Any untyped load
+ static const RAW = const ContentBlockerTriggerResourceType._internal('raw');
+
+ bool operator ==(value) => value == _value;
+
+ @override
+ int get hashCode => _value.hashCode;
+}
+
+
+///ContentBlockerTriggerLoadType class represents the possible load type for a [ContentBlockerTrigger].
+class ContentBlockerTriggerLoadType {
+ final String _value;
+ const ContentBlockerTriggerLoadType._internal(this._value);
+ static ContentBlockerTriggerLoadType fromValue(String value) {
+ return (["first-party", "third-party"].contains(value)) ? ContentBlockerTriggerLoadType._internal(value) : null;
+ }
+ String toValue() => _value;
+ @override
+ String toString() => _value;
+
+ ///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');
+ ///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');
+
+ bool operator ==(value) => value == _value;
+
+ @override
+ int get hashCode => _value.hashCode;
+}
+
+///ContentBlockerActionType class represents the kind of action that can be used with a [ContentBlockerTrigger].
+class ContentBlockerActionType {
+ final String _value;
+ const ContentBlockerActionType._internal(this._value);
+ static ContentBlockerActionType fromValue(String value) {
+ return (["block", "css-display-none", "make-https"].contains(value)) ? ContentBlockerActionType._internal(value) : null;
+ }
+ String toValue() => _value;
+ @override
+ String toString() => _value;
+
+ ///Stops loading of the resource. If the resource was cached, the cache is ignored.
+ static const BLOCK = const ContentBlockerActionType._internal('block');
+ ///Hides elements of the page based on a CSS selector. A selector field contains the selector list. Any matching element has its display property set to none, which hides it.
+ ///
+ ///**NOTE**: on Android, JavaScript must be enabled.
+ static const 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');
+
+ bool operator ==(value) => value == _value;
+
+ @override
+ int get hashCode => _value.hashCode;
+}
+
+///Cookie class represents a cookie returned by the [CookieManager].
+class Cookie {
+ ///The name;
+ String name;
+ ///The value;
+ dynamic value;
+
+ Cookie({@required this.name, @required this.value});
}
\ No newline at end of file
diff --git a/nodejs_server_test_auth_basic_and_ssl/index.js b/nodejs_server_test_auth_basic_and_ssl/index.js
index 7575c629..0f2f1a33 100644
--- a/nodejs_server_test_auth_basic_and_ssl/index.js
+++ b/nodejs_server_test_auth_basic_and_ssl/index.js
@@ -22,44 +22,56 @@ appHttps.get('/', (req, res) => {
console.log(JSON.stringify(req.headers))
const cert = req.connection.getPeerCertificate()
-// The `req.client.authorized` flag will be true if the certificate is valid and was issued by a CA we white-listed
-// earlier in `opts.ca`. We display the name of our user (CN = Common Name) and the name of the issuer, which is
-// `localhost`.
+ // The `req.client.authorized` flag will be true if the certificate is valid and was issued by a CA we white-listed
+ // earlier in `opts.ca`. We display the name of our user (CN = Common Name) and the name of the issuer, which is
+ // `localhost`.
if (req.client.authorized) {
res.send(`
-
-
-
-
-
- Hello ${cert.subject.CN}, your certificate was issued by ${cert.issuer.CN}!
-
-
- `)
-// They can still provide a certificate which is not accepted by us. Unfortunately, the `cert` object will be an empty
-// object instead of `null` if there is no certificate at all, so we have to check for a known field rather than
-// truthiness.
+
+
+
+
+ Authorized
+
+
+ `);
+ // They can still provide a certificate which is not accepted by us. Unfortunately, the `cert` object will be an empty
+ // object instead of `null` if there is no certificate at all, so we have to check for a known field rather than
+ // truthiness.
} else if (cert.subject) {
- res.status(403).send(`Sorry ${cert.subject.CN}, certificates from ${cert.issuer.CN} are not welcome here.`)
-// And last, they can come to us with no certificate at all:
+ console.log(`Sorry ${cert.subject.CN}, certificates from ${cert.issuer.CN} are not welcome here.`);
+ res.status(403).send(`
+
+
+
+
+ Forbidden
+
+
+ `);
+ // And last, they can come to us with no certificate at all:
} else {
- res.status(401).send(`Sorry, but you need to provide a client certificate to continue.`)
+ console.log(`Sorry, but you need to provide a client certificate to continue.`)
+ res.status(401).send(`
+
+
+
+
+ Unauthorized
+
+
+ `);
}
res.end()
})
-appHttps.get('/fakeResource', (req, res) => {
- console.log(JSON.stringify(req.headers))
- res.set("Content-Type", "text/javascript")
- res.send(`alert("HI");`)
- res.end()
-})
-
// Let's create our HTTPS server and we're ready to go.
https.createServer(options, appHttps).listen(4433)
+
+
// Ensure this is before any other middleware or routes
appAuthBasic.use((req, res, next) => {
let user = auth(req)
@@ -98,6 +110,8 @@ appAuthBasic.get("/", (req, res) => {
appAuthBasic.listen(8081)
+
+
// Parse URL-encoded bodies (as sent by HTML forms)
app.use(express.urlencoded());
diff --git a/test.sh b/test.sh
new file mode 100755
index 00000000..eace3a8a
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+export NODE_SERVER_IP=$1
+dart tool/env.dart
+cd nodejs_server_test_auth_basic_and_ssl
+node index.js &
+cd ../example
+flutter driver -t test_driver/app.dart
+kill $(jobs -p)
\ No newline at end of file
diff --git a/tool/env.dart b/tool/env.dart
new file mode 100644
index 00000000..655a260f
--- /dev/null
+++ b/tool/env.dart
@@ -0,0 +1,12 @@
+import 'dart:async';
+import 'dart:convert';
+import 'dart:io';
+
+Future main() async {
+ final config = {
+ 'NODE_SERVER_IP': Platform.environment['NODE_SERVER_IP'],
+ };
+
+ final filename = 'example/test_driver/.env.dart';
+ File(filename).writeAsString('final environment = ${json.encode(config)};');
+}
\ No newline at end of file