wasm-action 0.0.5__tar.gz → 0.0.7__tar.gz

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.
Files changed (72) hide show
  1. {wasm_action-0.0.5 → wasm_action-0.0.7}/PKG-INFO +32 -7
  2. {wasm_action-0.0.5 → wasm_action-0.0.7}/README.md +31 -6
  3. {wasm_action-0.0.5 → wasm_action-0.0.7}/pyproject.toml +1 -1
  4. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/cli.py +21 -0
  5. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/lib.py +0 -1
  6. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/warg/actions.py +4 -1
  7. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/warg/crypto.py +23 -2
  8. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/__init__.py +0 -0
  9. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/api/__init__.py +0 -0
  10. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/api/content_api.py +0 -0
  11. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/api/fetch_api.py +0 -0
  12. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/api/ledger_api.py +0 -0
  13. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/api/monitor_api.py +0 -0
  14. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/api/package_api.py +0 -0
  15. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/api/proof_api.py +0 -0
  16. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/api_client.py +0 -0
  17. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/api_response.py +0 -0
  18. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/configuration.py +0 -0
  19. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/exceptions.py +0 -0
  20. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/__init__.py +0 -0
  21. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/bundle_failure_error.py +0 -0
  22. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/checkpoint.py +0 -0
  23. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/checkpoint_verification_response.py +0 -0
  24. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/content_sources_response.py +0 -0
  25. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/envelope_body.py +0 -0
  26. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/error.py +0 -0
  27. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/fetch_logs404_response.py +0 -0
  28. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/fetch_logs_id_not_found_error.py +0 -0
  29. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/fetch_logs_log_length_not_found_error.py +0 -0
  30. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/fetch_logs_request.py +0 -0
  31. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/fetch_logs_response.py +0 -0
  32. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/fetch_names404_response.py +0 -0
  33. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/fetch_package_names_request.py +0 -0
  34. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/fetch_package_names_response.py +0 -0
  35. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/fetch_warning.py +0 -0
  36. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/get_content_sources404_response.py +0 -0
  37. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/get_package_record404_response.py +0 -0
  38. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/http_get.py +0 -0
  39. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/http_upload.py +0 -0
  40. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/http_upload_headers.py +0 -0
  41. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/incorrect_proof_error.py +0 -0
  42. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/ledger_sources_response.py +0 -0
  43. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/ledger_sources_response_sources_inner.py +0 -0
  44. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/missing_content.py +0 -0
  45. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/package_not_included_error.py +0 -0
  46. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/package_record.py +0 -0
  47. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/processing_record.py +0 -0
  48. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/prove_consistency404_response.py +0 -0
  49. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/prove_consistency_request.py +0 -0
  50. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/prove_consistency_response.py +0 -0
  51. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/prove_inclusion404_response.py +0 -0
  52. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/prove_inclusion422_response.py +0 -0
  53. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/prove_inclusion_request.py +0 -0
  54. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/prove_inclusion_response.py +0 -0
  55. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/publish_package_record404_response.py +0 -0
  56. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/publish_package_record409_response.py +0 -0
  57. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/publish_package_record_request.py +0 -0
  58. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/published_record.py +0 -0
  59. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/published_record_envelope.py +0 -0
  60. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/rejected_record.py +0 -0
  61. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/signature.py +0 -0
  62. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/signed_checkpoint.py +0 -0
  63. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/sourcing_record.py +0 -0
  64. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/models/timestamped_checkpoint.py +0 -0
  65. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/py.typed +0 -0
  66. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/warg_openapi/rest.py +0 -0
  67. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/__init__.py +0 -0
  68. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/registry.py +0 -0
  69. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/util.py +0 -0
  70. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/warg/__init__.py +0 -0
  71. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/warg/client.py +0 -0
  72. {wasm_action-0.0.5 → wasm_action-0.0.7}/src/wasm_action/warg/proto.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wasm-action
3
- Version: 0.0.5
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
- pull Pull from a WebAssembly registry
91
- push Push to a WebAssembly registry
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
@@ -9,17 +9,21 @@
9
9
  * Supported actions: push, pull
10
10
  * Supports Python 3.10+ on Linux, MacOS and Windows
11
11
 
12
+ #### Planned
13
+ * OCI registry support (a.k.a. Docker registry)
14
+ * Convert between formats (wit/wasm)
15
+
12
16
  ## Usage
13
17
  ### Pull from registry
14
18
  ```
15
- - uses: xelato/wasm-action
19
+ - uses: xelato/wasm-action@main
16
20
  with:
17
21
  action: pull
18
22
  registry: wa.dev
19
23
  package: component-book:adder
20
24
  ```
21
25
 
22
- To pull a private package define your [token](https://wa.dev/account/credentials/new):
26
+ To pull a private package, define your [token](https://wa.dev/account/credentials/new):
23
27
  ```
24
28
  env:
25
29
  WARG_TOKEN: ${{ secrets.WARG_TOKEN }}
@@ -48,7 +52,7 @@ To pull a private package define your [token](https://wa.dev/account/credentials
48
52
 
49
53
  ### Push to registry
50
54
  ```
51
- - uses: xelato/wasm-action
55
+ - uses: xelato/wasm-action@main
52
56
  with:
53
57
  action: push
54
58
  registry: wa.dev
@@ -59,8 +63,27 @@ To pull a private package define your [token](https://wa.dev/account/credentials
59
63
  WARG_PRIVATE_KEY: ${{ secrets.WARG_PRIVATE_KEY }}
60
64
  ```
61
65
 
66
+ ### Key generation
67
+ 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:
68
+ ```
69
+ $ uv run wasm-action key
70
+ {
71
+ "private": "ecdsa-p256:9y5nigLvFp3KZZQtuvN9DchpGIMUB4bwGAtkIoOCla4=",
72
+ "public": "ecdsa-p256:AvspSQWBK65ItTou/uVCi5qC4P+HBCi4R34OIPb3ILRl",
73
+ "id": "sha256:c836bd8a3082f2e8d70bdfa48296e580ab847fcdeadb351f448d03f152d44093"
74
+ }
75
+ ```
76
+ ```
77
+ # use private key to configure in github or save it elsewhere in a secure manner
78
+ $ uvx wasm-action key | jq .private | pbcopy
79
+ ```
80
+ ```
81
+ # use corresponding public key for new token registration at wa.dev
82
+ $ pbpaste | uvx wasm-action key | jq .public
83
+ ```
84
+
62
85
  ## CLI
63
- The tool can be run without installing using [uv](https://docs.astral.sh/uv/).
86
+ The tool can be run without installing, using [uv](https://docs.astral.sh/uv/).
64
87
  ```
65
88
  $ uvx wasm-action --help
66
89
  Usage: wasm-action [OPTIONS] COMMAND [ARGS]...
@@ -69,8 +92,10 @@ Options:
69
92
  --help Show this message and exit.
70
93
 
71
94
  Commands:
72
- pull Pull from a WebAssembly registry
73
- push Push to a WebAssembly registry
95
+ key Generate private key or read one from stdin
96
+ pull Pull from registry
97
+ push Push to registry
98
+ version Print version
74
99
  ```
75
100
  ```
76
101
  $ uvx wasm-action pull --help
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "wasm-action"
3
- version = "0.0.5"
3
+ version = "0.0.7"
4
4
  description = "Interact with WebAssembly registries."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -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()
@@ -5,7 +5,6 @@ import os
5
5
  import hashlib
6
6
  import base64
7
7
  import json
8
-
9
8
  import click
10
9
  import semver
11
10
  import validators
@@ -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':
@@ -38,9 +38,14 @@ class PrivateKey:
38
38
  """
39
39
  Decode a key in `<algo>:<base64>` format.
40
40
  """
41
- if ':' not in text:
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
- # todo: compare bytes length with curve key length
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
+ }