wasm-action 0.0.5__py3-none-any.whl → 0.0.7__py3-none-any.whl
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.
- wasm_action/cli.py +21 -0
- wasm_action/lib.py +0 -1
- wasm_action/warg/actions.py +4 -1
- wasm_action/warg/crypto.py +23 -2
- {wasm_action-0.0.5.dist-info → wasm_action-0.0.7.dist-info}/METADATA +32 -7
- {wasm_action-0.0.5.dist-info → wasm_action-0.0.7.dist-info}/RECORD +8 -8
- {wasm_action-0.0.5.dist-info → wasm_action-0.0.7.dist-info}/WHEEL +2 -2
- {wasm_action-0.0.5.dist-info → wasm_action-0.0.7.dist-info}/entry_points.txt +0 -0
wasm_action/cli.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
import click
|
|
3
3
|
import importlib.metadata
|
|
4
|
+
import json
|
|
4
5
|
|
|
5
6
|
from . import lib
|
|
7
|
+
from .warg.crypto import generate_key
|
|
8
|
+
|
|
6
9
|
|
|
7
10
|
@click.group()
|
|
8
11
|
def cli():
|
|
@@ -64,5 +67,23 @@ def pull(registry, package, path=None, warg_token=None):
|
|
|
64
67
|
sys.exit(1)
|
|
65
68
|
|
|
66
69
|
|
|
70
|
+
@cli.command(help="Generate private key or read one from stdin")
|
|
71
|
+
def key():
|
|
72
|
+
"""Generate key in json format.
|
|
73
|
+
|
|
74
|
+
Either:
|
|
75
|
+
- generate a new key
|
|
76
|
+
- read a private key from standard input
|
|
77
|
+
"""
|
|
78
|
+
if sys.stdin.isatty():
|
|
79
|
+
data = generate_key()
|
|
80
|
+
else:
|
|
81
|
+
# read private key from standard input
|
|
82
|
+
private_key = sys.stdin.read()
|
|
83
|
+
data = generate_key(private_key)
|
|
84
|
+
del data['private']
|
|
85
|
+
print(json.dumps(data, indent=4))
|
|
86
|
+
|
|
87
|
+
|
|
67
88
|
if __name__ == "__main__":
|
|
68
89
|
cli()
|
wasm_action/lib.py
CHANGED
wasm_action/warg/actions.py
CHANGED
|
@@ -60,11 +60,14 @@ def warg_push(registry, warg_url, namespace, name, version, content_bytes, warg_
|
|
|
60
60
|
|
|
61
61
|
# state: sourcing -> upload sources
|
|
62
62
|
elif state == 'sourcing':
|
|
63
|
+
time.sleep(1)
|
|
63
64
|
if 'missingContent' in res:
|
|
64
65
|
for _, data in res['missingContent'].items():
|
|
65
66
|
if 'upload' in data:
|
|
66
67
|
for upload in data['upload']:
|
|
67
|
-
requests.put(upload['url'], data=content_bytes)
|
|
68
|
+
r = requests.put(upload['url'], data=content_bytes)
|
|
69
|
+
if r.status_code not in (200, 201):
|
|
70
|
+
print(r.status_code, r.content)
|
|
68
71
|
|
|
69
72
|
# state: rejected -> error
|
|
70
73
|
elif state == 'rejected':
|
wasm_action/warg/crypto.py
CHANGED
|
@@ -38,9 +38,14 @@ class PrivateKey:
|
|
|
38
38
|
"""
|
|
39
39
|
Decode a key in `<algo>:<base64>` format.
|
|
40
40
|
"""
|
|
41
|
-
|
|
41
|
+
text = (text or '').strip()
|
|
42
|
+
if not text or ':' not in text:
|
|
42
43
|
raise ValueError('required format: <algo>:<base64>')
|
|
43
44
|
|
|
45
|
+
# better interplay with jq, pbcopy, and pbpaste
|
|
46
|
+
if len(text)>1 and text.startswith('"') and text.endswith('"'):
|
|
47
|
+
text = text[1:-1]
|
|
48
|
+
|
|
44
49
|
algo, key_b64 = text.split(':', 1)
|
|
45
50
|
|
|
46
51
|
curve = cls.CURVES.get(algo)
|
|
@@ -48,7 +53,9 @@ class PrivateKey:
|
|
|
48
53
|
raise ValueError('algorithm not supported: {}'.format(algo))
|
|
49
54
|
|
|
50
55
|
key_bytes = base64.b64decode(key_b64)
|
|
51
|
-
#
|
|
56
|
+
# compare bytes length with curve key size
|
|
57
|
+
if len(key_bytes) * 8 != curve.key_size:
|
|
58
|
+
raise ValueError('key size mismatch')
|
|
52
59
|
|
|
53
60
|
key_int = int.from_bytes(key_bytes, byteorder='big')
|
|
54
61
|
key = ec.derive_private_key(key_int, curve=curve)
|
|
@@ -134,3 +141,17 @@ class PublicKey:
|
|
|
134
141
|
def fingerprint(self):
|
|
135
142
|
"""Used as Key ID"""
|
|
136
143
|
return "sha256:{}".format(hashlib.sha256(self.canonical().encode('ascii')).hexdigest())
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def generate_key(private_key:str=None):
|
|
147
|
+
"""Generate key-pair."""
|
|
148
|
+
if private_key:
|
|
149
|
+
private = PrivateKey.load(private_key)
|
|
150
|
+
else:
|
|
151
|
+
private = PrivateKey.generate()
|
|
152
|
+
public = private.public_key()
|
|
153
|
+
return {
|
|
154
|
+
"private": private.canonical(),
|
|
155
|
+
"public": public.canonical(),
|
|
156
|
+
"id": public.fingerprint(),
|
|
157
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: wasm-action
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.7
|
|
4
4
|
Summary: Interact with WebAssembly registries.
|
|
5
5
|
Requires-Dist: click>=8.2.1
|
|
6
6
|
Requires-Dist: cryptography>=45.0.6
|
|
@@ -27,17 +27,21 @@ Description-Content-Type: text/markdown
|
|
|
27
27
|
* Supported actions: push, pull
|
|
28
28
|
* Supports Python 3.10+ on Linux, MacOS and Windows
|
|
29
29
|
|
|
30
|
+
#### Planned
|
|
31
|
+
* OCI registry support (a.k.a. Docker registry)
|
|
32
|
+
* Convert between formats (wit/wasm)
|
|
33
|
+
|
|
30
34
|
## Usage
|
|
31
35
|
### Pull from registry
|
|
32
36
|
```
|
|
33
|
-
- uses: xelato/wasm-action
|
|
37
|
+
- uses: xelato/wasm-action@main
|
|
34
38
|
with:
|
|
35
39
|
action: pull
|
|
36
40
|
registry: wa.dev
|
|
37
41
|
package: component-book:adder
|
|
38
42
|
```
|
|
39
43
|
|
|
40
|
-
To pull a private package define your [token](https://wa.dev/account/credentials/new):
|
|
44
|
+
To pull a private package, define your [token](https://wa.dev/account/credentials/new):
|
|
41
45
|
```
|
|
42
46
|
env:
|
|
43
47
|
WARG_TOKEN: ${{ secrets.WARG_TOKEN }}
|
|
@@ -66,7 +70,7 @@ To pull a private package define your [token](https://wa.dev/account/credentials
|
|
|
66
70
|
|
|
67
71
|
### Push to registry
|
|
68
72
|
```
|
|
69
|
-
- uses: xelato/wasm-action
|
|
73
|
+
- uses: xelato/wasm-action@main
|
|
70
74
|
with:
|
|
71
75
|
action: push
|
|
72
76
|
registry: wa.dev
|
|
@@ -77,8 +81,27 @@ To pull a private package define your [token](https://wa.dev/account/credentials
|
|
|
77
81
|
WARG_PRIVATE_KEY: ${{ secrets.WARG_PRIVATE_KEY }}
|
|
78
82
|
```
|
|
79
83
|
|
|
84
|
+
### Key generation
|
|
85
|
+
New [token](https://wa.dev/account/credentials/new) registration and push to wa.dev require generation and configuration of a private/public key pair which can be facilitated with:
|
|
86
|
+
```
|
|
87
|
+
$ uv run wasm-action key
|
|
88
|
+
{
|
|
89
|
+
"private": "ecdsa-p256:9y5nigLvFp3KZZQtuvN9DchpGIMUB4bwGAtkIoOCla4=",
|
|
90
|
+
"public": "ecdsa-p256:AvspSQWBK65ItTou/uVCi5qC4P+HBCi4R34OIPb3ILRl",
|
|
91
|
+
"id": "sha256:c836bd8a3082f2e8d70bdfa48296e580ab847fcdeadb351f448d03f152d44093"
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
```
|
|
95
|
+
# use private key to configure in github or save it elsewhere in a secure manner
|
|
96
|
+
$ uvx wasm-action key | jq .private | pbcopy
|
|
97
|
+
```
|
|
98
|
+
```
|
|
99
|
+
# use corresponding public key for new token registration at wa.dev
|
|
100
|
+
$ pbpaste | uvx wasm-action key | jq .public
|
|
101
|
+
```
|
|
102
|
+
|
|
80
103
|
## CLI
|
|
81
|
-
The tool can be run without installing using [uv](https://docs.astral.sh/uv/).
|
|
104
|
+
The tool can be run without installing, using [uv](https://docs.astral.sh/uv/).
|
|
82
105
|
```
|
|
83
106
|
$ uvx wasm-action --help
|
|
84
107
|
Usage: wasm-action [OPTIONS] COMMAND [ARGS]...
|
|
@@ -87,8 +110,10 @@ Options:
|
|
|
87
110
|
--help Show this message and exit.
|
|
88
111
|
|
|
89
112
|
Commands:
|
|
90
|
-
|
|
91
|
-
|
|
113
|
+
key Generate private key or read one from stdin
|
|
114
|
+
pull Pull from registry
|
|
115
|
+
push Push to registry
|
|
116
|
+
version Print version
|
|
92
117
|
```
|
|
93
118
|
```
|
|
94
119
|
$ uvx wasm-action pull --help
|
|
@@ -58,16 +58,16 @@ warg_openapi/models/timestamped_checkpoint.py,sha256=HvpqFUAzxb4AlhFOd1FHi8gKYAv
|
|
|
58
58
|
warg_openapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
59
59
|
warg_openapi/rest.py,sha256=esTaIvd-RN8XURlnK_ALzgEyd5n1853hJRoAdCe7C3k,14044
|
|
60
60
|
wasm_action/__init__.py,sha256=77Mz6_mfveQMO90YlCumicDwhzSa0Xvi3xpJ_10EYZ8,190
|
|
61
|
-
wasm_action/cli.py,sha256=
|
|
62
|
-
wasm_action/lib.py,sha256=
|
|
61
|
+
wasm_action/cli.py,sha256=Hwn7hIxfBom_h4RaNc3_o73KZMX5ZbLl52sfgoXeL2E,2345
|
|
62
|
+
wasm_action/lib.py,sha256=xX66hhbxyxI5GP_k4DfDdViWj0FonqFXBwq8ssAuZo4,5366
|
|
63
63
|
wasm_action/registry.py,sha256=JfsYJbzysbcgMAG9wf-8bPU-fmSm7wan_aReRXGGaMM,1497
|
|
64
64
|
wasm_action/util.py,sha256=TqIMicfNDqtjhTuLLBujpw77Z2ktY9uXmddsztg-Y8E,2247
|
|
65
65
|
wasm_action/warg/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
66
|
-
wasm_action/warg/actions.py,sha256=
|
|
66
|
+
wasm_action/warg/actions.py,sha256=RfP3REOJp0bxuJ3FkkXFjrO1zfWrW5v7T_HOb8-g6mE,4658
|
|
67
67
|
wasm_action/warg/client.py,sha256=FKKHcTwqAJotN3ZL2bIHJ0ET05YxRQw9ks8IyxDQ6Mo,6389
|
|
68
|
-
wasm_action/warg/crypto.py,sha256=
|
|
68
|
+
wasm_action/warg/crypto.py,sha256=eK2Vw1mLFg2wmL6_3jmLHKzo2JK3KpnOz4PRUFZowZY,4906
|
|
69
69
|
wasm_action/warg/proto.py,sha256=ui6rPfC_5IQQheOAwCxOL--r_tmvN-hc50NlLC5bgn4,6226
|
|
70
|
-
wasm_action-0.0.
|
|
71
|
-
wasm_action-0.0.
|
|
72
|
-
wasm_action-0.0.
|
|
73
|
-
wasm_action-0.0.
|
|
70
|
+
wasm_action-0.0.7.dist-info/WHEEL,sha256=XV0cjMrO7zXhVAIyyc8aFf1VjZ33Fen4IiJk5zFlC3g,80
|
|
71
|
+
wasm_action-0.0.7.dist-info/entry_points.txt,sha256=lTdloFNHGTiEbfd1efp0ZQ7p9SpAbzIWYqxk__EAPFE,53
|
|
72
|
+
wasm_action-0.0.7.dist-info/METADATA,sha256=4v6xz5MeK7IvMje08VegVoofZqQ-jkkSm3oDxqzLfXk,4892
|
|
73
|
+
wasm_action-0.0.7.dist-info/RECORD,,
|
|
File without changes
|