@supersdk/supercli 0.3.0-staging.27 → 0.3.0-staging.28
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.
|
@@ -18,6 +18,7 @@ REQUIRED_ASSETS = ("index.html", "js/app.js", "js/supersdk.js", "css/style.css")
|
|
|
18
18
|
EXCLUDED_ASSETS = {"__super_meta.json", ".DS_Store", "js/supersdk.provenance.json"}
|
|
19
19
|
HEX64 = set("0123456789abcdef")
|
|
20
20
|
VERSION_PATTERN = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+$")
|
|
21
|
+
INTEGRITY_PATTERN = re.compile(r"^sha512-[A-Za-z0-9+/]+={0,2}$")
|
|
21
22
|
CONFIG_FILENAME = "supersdk.json"
|
|
22
23
|
|
|
23
24
|
# `<project>/src` is authored input; `<project>/dist` is the single publishable build
|
|
@@ -72,12 +73,23 @@ def validate_provenance(root):
|
|
|
72
73
|
provenance = json.loads(provenance_path.read_text(encoding="utf-8"))
|
|
73
74
|
except (OSError, json.JSONDecodeError, UnicodeDecodeError) as exc:
|
|
74
75
|
raise WebPackageError("supersdk.provenance.json: invalid JSON") from exc
|
|
75
|
-
|
|
76
|
+
expected_fields = {"package", "version", "integrity", "file", "sha256"}
|
|
77
|
+
if not isinstance(provenance, dict) or set(provenance) != expected_fields:
|
|
78
|
+
raise WebPackageError("supersdk.provenance.json: fields must match public artifact schema")
|
|
79
|
+
if provenance.get("package") != "@supersdk/jssdk":
|
|
80
|
+
raise WebPackageError("supersdk.provenance.json: package must be @supersdk/jssdk")
|
|
81
|
+
if not isinstance(provenance.get("version"), str) or not VERSION_PATTERN.fullmatch(provenance["version"]):
|
|
82
|
+
raise WebPackageError("supersdk.provenance.json: version must be x.y.z")
|
|
83
|
+
if not isinstance(provenance.get("integrity"), str) or not INTEGRITY_PATTERN.fullmatch(provenance["integrity"]):
|
|
84
|
+
raise WebPackageError("supersdk.provenance.json: integrity must be sha512 SRI")
|
|
85
|
+
if provenance.get("file") != "dist/supersdk.js":
|
|
86
|
+
raise WebPackageError("supersdk.provenance.json: file must be dist/supersdk.js")
|
|
87
|
+
vendored_hash = provenance.get("sha256")
|
|
76
88
|
if not isinstance(vendored_hash, str) or len(vendored_hash) != 64 or any(ch not in HEX64 for ch in vendored_hash):
|
|
77
|
-
raise WebPackageError("supersdk.provenance.json:
|
|
89
|
+
raise WebPackageError("supersdk.provenance.json: sha256 must be 64 hex")
|
|
78
90
|
actual = hashlib.sha256(vendored_path.read_bytes()).hexdigest()
|
|
79
91
|
if actual != vendored_hash:
|
|
80
|
-
raise WebPackageError("supersdk.provenance.json:
|
|
92
|
+
raise WebPackageError("supersdk.provenance.json: sha256 mismatch")
|
|
81
93
|
|
|
82
94
|
|
|
83
95
|
def validate_inputs(src, host, version, require_provenance=True):
|
|
@@ -129,10 +129,11 @@
|
|
|
129
129
|
var environment = readEnvironment();
|
|
130
130
|
setPickerEnabled(true, environment);
|
|
131
131
|
return loadConfig().then(function(config) {
|
|
132
|
-
window.SuperSDK.
|
|
132
|
+
window.SuperSDK.init({
|
|
133
133
|
spid: config.spid,
|
|
134
134
|
environment: environment,
|
|
135
|
-
appName: config.name
|
|
135
|
+
appName: config.name,
|
|
136
|
+
analyticsConsent: "denied"
|
|
136
137
|
});
|
|
137
138
|
clearDiagnostic();
|
|
138
139
|
renderConfig(config, environment);
|