edgeway 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +43 -19
- data/js/cgi.js +11 -20
- data/js/cloudflare.js +25 -0
- data/js/jwt.js +1 -1
- data/js/runtime.js +6 -4
- data/lib/edgeway/cache/store.rb +2 -2
- data/lib/edgeway/cli/build/app_files.rb +22 -18
- data/lib/edgeway/cli/build/class_source.rb +21 -0
- data/lib/edgeway/cli/build/cloudflare_platform.rb +56 -0
- data/lib/edgeway/cli/build/dispatch_compiler.rb +71 -0
- data/lib/edgeway/cli/build/dispatch_probe.rb +52 -0
- data/lib/edgeway/cli/build/js_files.rb +12 -4
- data/lib/edgeway/cli/build/platform_config.rb +36 -0
- data/lib/edgeway/cli/build/view_compiler.rb +2 -11
- data/lib/edgeway/cli/build.rb +67 -28
- data/lib/edgeway/cli/cloudflare_test.rb +5 -2
- data/lib/edgeway/cli/generate.rb +11 -10
- data/lib/edgeway/cli/test.rb +11 -3
- data/lib/edgeway/cli/toolchain.rb +3 -3
- data/lib/edgeway/cli.rb +1 -1
- data/lib/edgeway/controller/base.rb +4 -2
- data/lib/edgeway/controller/{authentication.rb → bearer_token_authentication.rb} +4 -5
- data/lib/edgeway/controller/caching.rb +1 -2
- data/lib/edgeway/controller/dispatcher.rb +11 -21
- data/lib/edgeway/controller/rate_limiting.rb +1 -2
- data/lib/edgeway/errors.rb +1 -1
- data/lib/edgeway/generators/app/templates/README.md.tt +1 -1
- data/lib/edgeway/generators/app/templates/config/edgeway.yml +2 -0
- data/lib/edgeway/generators/app/templates/mise.toml.tt +1 -1
- data/lib/edgeway/http/form_body.rb +31 -0
- data/lib/edgeway/http/request.rb +3 -13
- data/lib/edgeway/model/attributes.rb +11 -6
- data/lib/edgeway/routing/mapper.rb +5 -5
- data/lib/edgeway/routing/route_set.rb +2 -2
- data/lib/edgeway/service/jwt.rb +30 -0
- data/lib/edgeway/version.rb +1 -1
- data/lib/edgeway.rb +2 -2
- metadata +11 -4
- data/lib/edgeway/service/cloudflare/jwt.rb +0 -32
|
@@ -17,11 +17,11 @@ module Edgeway
|
|
|
17
17
|
|
|
18
18
|
def root(to:) = add("GET", "/", to)
|
|
19
19
|
|
|
20
|
-
def namespace(name)
|
|
21
|
-
|
|
20
|
+
def namespace(name, &block)
|
|
21
|
+
block.call(Mapper.new(@routes, "#{@path_prefix}/#{name}", "#{@module_prefix}#{name}/"))
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def resources(name, only: [], except: [])
|
|
24
|
+
def resources(name, only: [], except: [], &block)
|
|
25
25
|
base = "/#{name}"
|
|
26
26
|
member = "#{base}/:id"
|
|
27
27
|
(only + except).each do |a|
|
|
@@ -39,8 +39,8 @@ module Edgeway
|
|
|
39
39
|
add("PUT", member, "#{name}#update")
|
|
40
40
|
end
|
|
41
41
|
add("DELETE", member, "#{name}#destroy") if want.include?("destroy")
|
|
42
|
-
if
|
|
43
|
-
|
|
42
|
+
if block
|
|
43
|
+
block.call(Mapper.new(@routes, "#{@path_prefix}#{base}/:#{Mapper.singular(name)}_id", @module_prefix))
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# JWT signature checks through the wasm import module
|
|
2
|
+
# "edgeway_jwt" that js/jwt.js implements. Only wasm builds load this file
|
|
3
|
+
# (ffi_source is Spinel's; tests use edgeway/http/auth/stub).
|
|
4
|
+
require "json"
|
|
5
|
+
require_relative "../http/auth/jwt"
|
|
6
|
+
require_relative "import_result"
|
|
7
|
+
|
|
8
|
+
module Edgeway
|
|
9
|
+
module JWTImports
|
|
10
|
+
ffi_source <<~C
|
|
11
|
+
#define JWT_IMPORT(name) __attribute__((import_module("edgeway_jwt"), import_name(name)))
|
|
12
|
+
|
|
13
|
+
JWT_IMPORT("verify") int js_jwt_verify(const char *token);
|
|
14
|
+
JWT_IMPORT("take") void js_jwt_take(char *buf);
|
|
15
|
+
|
|
16
|
+
static ImportResultBuffer jwt_result;
|
|
17
|
+
|
|
18
|
+
const char *jwt_verify(const char *token) {
|
|
19
|
+
return take_import_result(&jwt_result, js_jwt_verify(token), js_jwt_take);
|
|
20
|
+
}
|
|
21
|
+
C
|
|
22
|
+
ffi_func :jwt_verify, [:str], :str
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class JWTVerifier < Auth::Verifier
|
|
26
|
+
def verify(token)
|
|
27
|
+
JWTImports.jwt_verify(token)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/edgeway/version.rb
CHANGED
data/lib/edgeway.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require "digest"
|
|
2
2
|
require "json"
|
|
3
3
|
require "time"
|
|
4
|
-
require "uri"
|
|
5
4
|
require_relative "edgeway/version"
|
|
6
5
|
require_relative "edgeway/errors"
|
|
7
6
|
require_relative "edgeway/inflector"
|
|
@@ -11,6 +10,7 @@ require_relative "edgeway/logger"
|
|
|
11
10
|
require_relative "edgeway/http/response"
|
|
12
11
|
require_relative "edgeway/http/parameters"
|
|
13
12
|
require_relative "edgeway/http/json_body"
|
|
13
|
+
require_relative "edgeway/http/form_body"
|
|
14
14
|
require_relative "edgeway/http/request"
|
|
15
15
|
require_relative "edgeway/http/client"
|
|
16
16
|
require_relative "edgeway/routing/route"
|
|
@@ -30,7 +30,7 @@ require_relative "edgeway/http/auth/jwt"
|
|
|
30
30
|
require_relative "edgeway/controller/callbacks"
|
|
31
31
|
require_relative "edgeway/controller/rescuable"
|
|
32
32
|
require_relative "edgeway/controller/rendering"
|
|
33
|
-
require_relative "edgeway/controller/
|
|
33
|
+
require_relative "edgeway/controller/bearer_token_authentication"
|
|
34
34
|
require_relative "edgeway/controller/caching"
|
|
35
35
|
require_relative "edgeway/controller/rate_limiting"
|
|
36
36
|
require_relative "edgeway/controller/base"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: edgeway
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yuji Yaginuma
|
|
@@ -46,8 +46,13 @@ files:
|
|
|
46
46
|
- lib/edgeway/cli/build/app_config.rb
|
|
47
47
|
- lib/edgeway/cli/build/app_files.rb
|
|
48
48
|
- lib/edgeway/cli/build/cache_config.rb
|
|
49
|
+
- lib/edgeway/cli/build/class_source.rb
|
|
50
|
+
- lib/edgeway/cli/build/cloudflare_platform.rb
|
|
49
51
|
- lib/edgeway/cli/build/database_config.rb
|
|
52
|
+
- lib/edgeway/cli/build/dispatch_compiler.rb
|
|
53
|
+
- lib/edgeway/cli/build/dispatch_probe.rb
|
|
50
54
|
- lib/edgeway/cli/build/js_files.rb
|
|
55
|
+
- lib/edgeway/cli/build/platform_config.rb
|
|
51
56
|
- lib/edgeway/cli/build/view_compiler.rb
|
|
52
57
|
- lib/edgeway/cli/cloudflare_test.rb
|
|
53
58
|
- lib/edgeway/cli/cloudflare_test/wasm_test_cli.rb
|
|
@@ -59,8 +64,8 @@ files:
|
|
|
59
64
|
- lib/edgeway/cli/test.rb
|
|
60
65
|
- lib/edgeway/cli/toolchain.rb
|
|
61
66
|
- lib/edgeway/config.rb
|
|
62
|
-
- lib/edgeway/controller/authentication.rb
|
|
63
67
|
- lib/edgeway/controller/base.rb
|
|
68
|
+
- lib/edgeway/controller/bearer_token_authentication.rb
|
|
64
69
|
- lib/edgeway/controller/caching.rb
|
|
65
70
|
- lib/edgeway/controller/callbacks.rb
|
|
66
71
|
- lib/edgeway/controller/dispatcher.rb
|
|
@@ -87,6 +92,7 @@ files:
|
|
|
87
92
|
- lib/edgeway/generators/app/templates/bin/test.tt
|
|
88
93
|
- lib/edgeway/generators/app/templates/config/cache.yml
|
|
89
94
|
- lib/edgeway/generators/app/templates/config/database.yml
|
|
95
|
+
- lib/edgeway/generators/app/templates/config/edgeway.yml
|
|
90
96
|
- lib/edgeway/generators/app/templates/config/routes.rb
|
|
91
97
|
- lib/edgeway/generators/app/templates/db/migrations/.keep
|
|
92
98
|
- lib/edgeway/generators/app/templates/mise.toml.tt
|
|
@@ -99,6 +105,7 @@ files:
|
|
|
99
105
|
- lib/edgeway/http/auth/jwt.rb
|
|
100
106
|
- lib/edgeway/http/auth/stub.rb
|
|
101
107
|
- lib/edgeway/http/client.rb
|
|
108
|
+
- lib/edgeway/http/form_body.rb
|
|
102
109
|
- lib/edgeway/http/json_body.rb
|
|
103
110
|
- lib/edgeway/http/parameters.rb
|
|
104
111
|
- lib/edgeway/http/request.rb
|
|
@@ -122,7 +129,6 @@ files:
|
|
|
122
129
|
- lib/edgeway/routing/route_set.rb
|
|
123
130
|
- lib/edgeway/server.rb
|
|
124
131
|
- lib/edgeway/service/cloudflare/d1.rb
|
|
125
|
-
- lib/edgeway/service/cloudflare/jwt.rb
|
|
126
132
|
- lib/edgeway/service/cloudflare/kv.rb
|
|
127
133
|
- lib/edgeway/service/cloudflare/kv_store.rb
|
|
128
134
|
- lib/edgeway/service/cloudflare/rate_limit.rb
|
|
@@ -130,6 +136,7 @@ files:
|
|
|
130
136
|
- lib/edgeway/service/cloudflare/test_databases.rb
|
|
131
137
|
- lib/edgeway/service/fetch.rb
|
|
132
138
|
- lib/edgeway/service/import_result.rb
|
|
139
|
+
- lib/edgeway/service/jwt.rb
|
|
133
140
|
- lib/edgeway/test.rb
|
|
134
141
|
- lib/edgeway/test/sqlite_databases.rb
|
|
135
142
|
- lib/edgeway/version.rb
|
|
@@ -155,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
155
162
|
- !ruby/object:Gem::Version
|
|
156
163
|
version: '0'
|
|
157
164
|
requirements: []
|
|
158
|
-
rubygems_version: 4.0.
|
|
165
|
+
rubygems_version: 4.0.20
|
|
159
166
|
specification_version: 4
|
|
160
167
|
summary: A library for Ruby compiled by Spinel to wasm on edge workers.
|
|
161
168
|
test_files: []
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# JWT signature checks on Cloudflare Workers, through the wasm import module
|
|
2
|
-
# "edgeway_jwt" that js/jwt.js implements. Only wasm builds load this file
|
|
3
|
-
# (ffi_source is Spinel's; tests use edgeway/http/auth/stub).
|
|
4
|
-
require "json"
|
|
5
|
-
require_relative "../../http/auth/jwt"
|
|
6
|
-
require_relative "../import_result"
|
|
7
|
-
|
|
8
|
-
module Edgeway
|
|
9
|
-
module Cloudflare
|
|
10
|
-
module JWTImports
|
|
11
|
-
ffi_source <<~C
|
|
12
|
-
#define JWT_IMPORT(name) __attribute__((import_module("edgeway_jwt"), import_name(name)))
|
|
13
|
-
|
|
14
|
-
JWT_IMPORT("verify") int js_jwt_verify(const char *token);
|
|
15
|
-
JWT_IMPORT("take") void js_jwt_take(char *buf);
|
|
16
|
-
|
|
17
|
-
static ImportResultBuffer jwt_result;
|
|
18
|
-
|
|
19
|
-
const char *jwt_verify(const char *token) {
|
|
20
|
-
return take_import_result(&jwt_result, js_jwt_verify(token), js_jwt_take);
|
|
21
|
-
}
|
|
22
|
-
C
|
|
23
|
-
ffi_func :jwt_verify, [:str], :str
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
class JWTVerifier < Auth::Verifier
|
|
27
|
-
def verify(token)
|
|
28
|
-
JWTImports.jwt_verify(token)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|