@camox/api-contract 0.57.0 → 0.58.1
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.
- package/dist/index.d.ts +6 -0
- package/dist/index.js +12 -1
- package/dist/router.d.ts +198 -129
- package/package.json +1 -1
- package/src/artifact.ts +12 -0
package/package.json
CHANGED
package/src/artifact.ts
CHANGED
|
@@ -36,3 +36,15 @@ export function artifactSourceTitle(source: string): string | undefined {
|
|
|
36
36
|
export function artifactTitle(source: string): string {
|
|
37
37
|
return artifactSourceTitle(source) ?? UNTITLED_ARTIFACT;
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The hash an artifact source is stored and served under: the SHA-256 of its UTF-8 bytes, in
|
|
42
|
+
* URL-safe base64 without padding. Shared by the API, which stores sources under it, and the SDK,
|
|
43
|
+
* which names the URLs public pages load artifacts from.
|
|
44
|
+
*/
|
|
45
|
+
export async function artifactSourceHash(source: string): Promise<string> {
|
|
46
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(source));
|
|
47
|
+
let binary = "";
|
|
48
|
+
for (const byte of new Uint8Array(digest)) binary += String.fromCharCode(byte);
|
|
49
|
+
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
50
|
+
}
|