-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
211 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
import 'cloudflare_interop.dart'; | ||
export 'package:v8_runtime/v8_runtime.dart'; | ||
|
||
|
||
// TODO | ||
export './public/cache_storage.dart'; | ||
export './public/html_rewriter.dart' | ||
show | ||
HTMLRewriter, | ||
ContentOptions, | ||
ElementHandler, | ||
DocumentHandler, | ||
Doctype, | ||
Comment, | ||
Text, | ||
DocumentEnd, | ||
Element, | ||
EndTag; | ||
export './public/request.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
packages/cloudflare_workers/lib/interop/request_interop.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import 'dart:js_util' as js_util; | ||
import 'package:js/js.dart'; | ||
import 'package:js_bindings/js_bindings.dart' as interop; | ||
|
||
extension CloudflareWorkersRequestInteropExtension on interop.Request { | ||
IncomingRequestCfProperties get cf => js_util.getProperty(this, 'cf'); | ||
} | ||
|
||
@JS() | ||
@anonymous | ||
class IncomingRequestCfProperties { | ||
/// (e.g. 395747) | ||
external int get asn; | ||
|
||
/// The organization which owns the ASN of the incoming request. | ||
/// (e.g. Google Cloud) | ||
external String get asOrganization; | ||
external IncomingRequestCfPropertiesBotManagement? get botManagement; | ||
external String? get city; | ||
external String? get clientAcceptEncoding; | ||
external num get clientTcpRtt; | ||
external num get clientTrustScore; | ||
|
||
/// The three-letter airport code of the data center that the request | ||
/// hit. (e.g. "DFW") | ||
external String get colo; | ||
external String? get continent; | ||
|
||
/// The two-letter country code in the request. This is the same value | ||
/// as that provided in the CF-IPCountry header. (e.g. "US") | ||
external String get country; | ||
external String get httpProtocol; | ||
external String? get latitude; | ||
external String? get longitude; | ||
|
||
/// DMA metro code from which the request was issued, e.g. "635" | ||
external String? get metroCode; | ||
external String? get postalCode; | ||
|
||
/// e.g. "Texas" | ||
external String? get region; | ||
|
||
/// e.g. "TX" | ||
external String? get regionCode; | ||
|
||
/// e.g. "weight=256;exclusive=1" | ||
external String get requestPriority; | ||
|
||
/// e.g. "America/Chicago" | ||
external String? get timezone; | ||
external String get tlsVersion; | ||
external String get tlsCipher; | ||
external IncomingRequestCfPropertiesTLSClientAuth get tlsClientAuth; | ||
} | ||
|
||
@JS() | ||
@anonymous | ||
class IncomingRequestCfPropertiesBotManagement { | ||
external int get score; | ||
external bool get staticResource; | ||
external bool get verifiedBot; | ||
} | ||
|
||
@JS() | ||
@anonymous | ||
class IncomingRequestCfPropertiesTLSClientAuth { | ||
external String get certIssuerDNLegacy; | ||
external String get certIssuerDN; | ||
external String get certPresented; | ||
external String get certSubjectDNLegacy; | ||
external String get certSubjectDN; | ||
|
||
/// In format "Dec 22 19:39:00 2018 GMT" | ||
external String get certNotBefore; | ||
|
||
/// In format "Dec 22 19:39:00 2018 GMT" | ||
external String get certNotAfter; | ||
external String get certSerial; | ||
external String get certFingerprintSHA1; | ||
|
||
/// "SUCCESS", "FAILED:reason", "NONE" | ||
external String get certVerified; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'package:v8_runtime/v8_runtime.dart'; | ||
import 'package:v8_runtime/public/cache.dart'; | ||
|
||
import '../interop/cache_interop.dart' as interop; | ||
|
||
extension CloudflareWorkersCacheStorageExtension on CacheStorage { | ||
Cache get defaultCache => cacheFromJsObject(interop.defaultCache); | ||
} |
10 changes: 4 additions & 6 deletions
10
...ages/v8_runtime/lib/cf_html_rewriter.dart → ...are_workers/lib/public/html_rewriter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'package:v8_runtime/public/request.dart'; | ||
|
||
import '../interop/request_interop.dart' as interop; | ||
|
||
extension CloudflareWorkersRequestExtension on Request { | ||
IncomingRequestCfProperties get cf => | ||
IncomingRequestCfProperties._(delegate.cf); | ||
} | ||
|
||
class IncomingRequestCfProperties { | ||
final interop.IncomingRequestCfProperties _delegate; | ||
|
||
IncomingRequestCfProperties._(this._delegate); | ||
|
||
/// (e.g. 395747) | ||
int get asn => _delegate.asn; | ||
|
||
/// The organization which owns the ASN of the incoming request. | ||
/// (e.g. Google Cloud) | ||
String get asOrganization => _delegate.asOrganization; | ||
IncomingRequestCfPropertiesBotManagement? get botManagement { | ||
final obj = _delegate.botManagement; | ||
if (obj == null) return null; | ||
return IncomingRequestCfPropertiesBotManagement._(obj); | ||
} | ||
|
||
String? get city => _delegate.city; | ||
String? get clientAcceptEncoding => _delegate.clientAcceptEncoding; | ||
num get clientTcpRtt => _delegate.clientTcpRtt; | ||
num get clientTrustScore => _delegate.clientTrustScore; | ||
|
||
/// The three-letter airport code of the data center that the request | ||
/// hit. (e.g. "DFW") | ||
String get colo => _delegate.colo; | ||
String? get continent => _delegate.continent; | ||
|
||
/// The two-letter country code in the request. This is the same value | ||
/// as that provided in the CF-IPCountry header. (e.g. "US") | ||
String get country => _delegate.country; | ||
String get httpProtocol => _delegate.httpProtocol; | ||
String? get latitude => _delegate.latitude; | ||
String? get longitude => _delegate.longitude; | ||
|
||
/// DMA metro code from which the request was issued, e.g. "635" | ||
String? get metroCode => _delegate.metroCode; | ||
String? get postalCode => _delegate.postalCode; | ||
|
||
/// e.g. "Texas" | ||
String? get region => _delegate.region; | ||
|
||
/// e.g. "TX" | ||
String? get regionCode => _delegate.regionCode; | ||
|
||
/// e.g. "weight=256;exclusive=1" | ||
String get requestPriority => _delegate.requestPriority; | ||
|
||
/// e.g. "America/Chicago" | ||
String? get timezone => _delegate.timezone; | ||
String get tlsVersion => _delegate.tlsVersion; | ||
String get tlsCipher => _delegate.tlsCipher; | ||
IncomingRequestCfPropertiesTLSClientAuth get tlsClientAuth => | ||
IncomingRequestCfPropertiesTLSClientAuth._(_delegate.tlsClientAuth); | ||
} | ||
|
||
class IncomingRequestCfPropertiesBotManagement { | ||
final interop.IncomingRequestCfPropertiesBotManagement _delegate; | ||
IncomingRequestCfPropertiesBotManagement._(this._delegate); | ||
int get score => _delegate.score; | ||
bool get staticResource => _delegate.staticResource; | ||
bool get verifiedBot => _delegate.verifiedBot; | ||
} | ||
|
||
class IncomingRequestCfPropertiesTLSClientAuth { | ||
final interop.IncomingRequestCfPropertiesTLSClientAuth _delegate; | ||
IncomingRequestCfPropertiesTLSClientAuth._(this._delegate); | ||
|
||
String get certIssuerDNLegacy => _delegate.certIssuerDNLegacy; | ||
String get certIssuerDN => _delegate.certIssuerDN; | ||
String get certPresented => _delegate.certPresented; | ||
String get certSubjectDNLegacy => _delegate.certSubjectDNLegacy; | ||
String get certSubjectDN => _delegate.certSubjectDN; | ||
|
||
/// In format "Dec 22 19:39:00 2018 GMT" | ||
String get certNotBefore => _delegate.certNotBefore; | ||
|
||
/// In format "Dec 22 19:39:00 2018 GMT" | ||
String get certNotAfter => _delegate.certNotAfter; | ||
String get certSerial => _delegate.certSerial; | ||
String get certFingerprintSHA1 => _delegate.certFingerprintSHA1; | ||
|
||
/// "SUCCESS", "FAILED:reason", "NONE" | ||
String get certVerified => _delegate.certVerified; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ environment: | |
|
||
dependencies: | ||
v8_runtime: 0.0.1 | ||
js_bindings: ^0.0.8 | ||
js: ^0.6.5 | ||
|
||
dev_dependencies: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import 'package:js/js.dart' as js; | ||
import 'package:js_bindings/js_bindings.dart' as interop; | ||
|
||
export 'cf_cache_interop.dart' show defaultCache; | ||
|
||
@js.JS('caches') | ||
external interop.CacheStorage get caches; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import 'package:js/js.dart' as js; | ||
import 'package:js_bindings/js_bindings.dart' as interop; | ||
|
||
export 'cf_cache_interop.dart' show defaultCache; | ||
|
||
@js.JS('crypto') | ||
external interop.Crypto get crypto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters