@shard-for-obsidian/lib 0.2.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.
- package/README.md +77 -0
- package/dist/client/FetchAdapter.d.ts +14 -0
- package/dist/client/FetchAdapter.d.ts.map +1 -0
- package/dist/client/FetchAdapter.js +1 -0
- package/dist/client/OciRegistryClient.d.ts +196 -0
- package/dist/client/OciRegistryClient.d.ts.map +1 -0
- package/dist/client/OciRegistryClient.js +704 -0
- package/dist/client/RegistryClientOptions.d.ts +18 -0
- package/dist/client/RegistryClientOptions.d.ts.map +1 -0
- package/dist/client/RegistryClientOptions.js +1 -0
- package/dist/errors/RegistryErrors.d.ts +39 -0
- package/dist/errors/RegistryErrors.d.ts.map +1 -0
- package/dist/errors/RegistryErrors.js +52 -0
- package/dist/ghcr/GhcrConstants.d.ts +5 -0
- package/dist/ghcr/GhcrConstants.d.ts.map +1 -0
- package/dist/ghcr/GhcrConstants.js +4 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +7 -0
- package/dist/parsing/IndexParser.d.ts +26 -0
- package/dist/parsing/IndexParser.d.ts.map +1 -0
- package/dist/parsing/IndexParser.js +106 -0
- package/dist/parsing/LinkHeaderParser.d.ts +8 -0
- package/dist/parsing/LinkHeaderParser.d.ts.map +1 -0
- package/dist/parsing/LinkHeaderParser.js +34 -0
- package/dist/parsing/RepoParser.d.ts +54 -0
- package/dist/parsing/RepoParser.d.ts.map +1 -0
- package/dist/parsing/RepoParser.js +186 -0
- package/dist/types/AuthTypes.d.ts +14 -0
- package/dist/types/AuthTypes.d.ts.map +1 -0
- package/dist/types/AuthTypes.js +4 -0
- package/dist/types/ManifestTypes.d.ts +98 -0
- package/dist/types/ManifestTypes.d.ts.map +1 -0
- package/dist/types/ManifestTypes.js +7 -0
- package/dist/types/RegistryTypes.d.ts +48 -0
- package/dist/types/RegistryTypes.d.ts.map +1 -0
- package/dist/types/RegistryTypes.js +4 -0
- package/dist/types/RequestTypes.d.ts +23 -0
- package/dist/types/RequestTypes.d.ts.map +1 -0
- package/dist/types/RequestTypes.js +4 -0
- package/dist/utils/DigestUtils.d.ts +9 -0
- package/dist/utils/DigestUtils.d.ts.map +1 -0
- package/dist/utils/DigestUtils.js +26 -0
- package/dist/utils/ValidationUtils.d.ts +2 -0
- package/dist/utils/ValidationUtils.d.ts.map +1 -0
- package/dist/utils/ValidationUtils.js +6 -0
- package/package.json +50 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export declare const MEDIATYPE_MANIFEST_V2 = "application/vnd.docker.distribution.manifest.v2+json";
|
|
2
|
+
export declare const MEDIATYPE_MANIFEST_LIST_V2 = "application/vnd.docker.distribution.manifest.list.v2+json";
|
|
3
|
+
export declare const MEDIATYPE_OCI_MANIFEST_V1 = "application/vnd.oci.image.manifest.v1+json";
|
|
4
|
+
export declare const MEDIATYPE_OCI_MANIFEST_INDEX_V1 = "application/vnd.oci.image.index.v1+json";
|
|
5
|
+
export declare const MEDIATYPE_OBSIDIAN_PLUGIN_CONFIG_V1 = "application/vnd.obsidianmd.plugin-manifest.v1+json";
|
|
6
|
+
export declare const DEFAULT_USERAGENT: string;
|
|
7
|
+
export type Manifest = ManifestV2 | ManifestV2List | ManifestOCI | ManifestOCIIndex;
|
|
8
|
+
export interface ManifestV2 {
|
|
9
|
+
schemaVersion: 2;
|
|
10
|
+
mediaType: "application/vnd.docker.distribution.manifest.v2+json";
|
|
11
|
+
config: ManifestV2Descriptor;
|
|
12
|
+
layers: Array<ManifestV2Descriptor>;
|
|
13
|
+
}
|
|
14
|
+
export interface ManifestV2Descriptor {
|
|
15
|
+
mediaType: string;
|
|
16
|
+
size: number;
|
|
17
|
+
digest: string;
|
|
18
|
+
urls?: Array<string>;
|
|
19
|
+
}
|
|
20
|
+
export interface ManifestV2List {
|
|
21
|
+
schemaVersion: 2;
|
|
22
|
+
mediaType: "application/vnd.docker.distribution.manifest.list.v2+json";
|
|
23
|
+
manifests: Array<{
|
|
24
|
+
mediaType: string;
|
|
25
|
+
digest: string;
|
|
26
|
+
size: number;
|
|
27
|
+
platform: {
|
|
28
|
+
architecture: string;
|
|
29
|
+
os: string;
|
|
30
|
+
"os.version"?: string;
|
|
31
|
+
"os.features"?: string[];
|
|
32
|
+
variant?: string;
|
|
33
|
+
features?: string[];
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
export interface ManifestOCI {
|
|
38
|
+
schemaVersion: 2;
|
|
39
|
+
mediaType?: "application/vnd.oci.image.manifest.v1+json";
|
|
40
|
+
artifactType?: string;
|
|
41
|
+
config: ManifestOCIDescriptor;
|
|
42
|
+
layers: Array<ManifestOCIDescriptor>;
|
|
43
|
+
annotations?: Record<string, string>;
|
|
44
|
+
}
|
|
45
|
+
export interface ManifestOCIDescriptor {
|
|
46
|
+
mediaType: string;
|
|
47
|
+
size: number;
|
|
48
|
+
digest: string;
|
|
49
|
+
urls?: Array<string>;
|
|
50
|
+
annotations?: Record<string, string>;
|
|
51
|
+
}
|
|
52
|
+
export interface ManifestOCIIndex {
|
|
53
|
+
schemaVersion: 2;
|
|
54
|
+
mediaType?: "application/vnd.oci.image.index.v1+json";
|
|
55
|
+
manifests: Array<{
|
|
56
|
+
mediaType: string;
|
|
57
|
+
digest: string;
|
|
58
|
+
size: number;
|
|
59
|
+
platform?: {
|
|
60
|
+
architecture: string;
|
|
61
|
+
os: string;
|
|
62
|
+
"os.version"?: string;
|
|
63
|
+
"os.features"?: string[];
|
|
64
|
+
variant?: string;
|
|
65
|
+
features?: string[];
|
|
66
|
+
};
|
|
67
|
+
/** Used for OCI Image Layouts */
|
|
68
|
+
annotations?: Record<string, string>;
|
|
69
|
+
}>;
|
|
70
|
+
annotations?: Record<string, string>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Obsidian plugin manifest structure
|
|
74
|
+
* Stored in OCI image config field
|
|
75
|
+
*/
|
|
76
|
+
export interface ObsidianManifest {
|
|
77
|
+
/** Plugin ID */
|
|
78
|
+
id: string;
|
|
79
|
+
/** Display name */
|
|
80
|
+
name: string;
|
|
81
|
+
/** Plugin version */
|
|
82
|
+
version: string;
|
|
83
|
+
/** Minimum Obsidian version required */
|
|
84
|
+
minAppVersion: string;
|
|
85
|
+
/** Plugin description */
|
|
86
|
+
description: string;
|
|
87
|
+
/** Plugin author */
|
|
88
|
+
author: string;
|
|
89
|
+
/** Author URL (optional) */
|
|
90
|
+
authorUrl?: string;
|
|
91
|
+
/** Is desktop only? (optional) */
|
|
92
|
+
isDesktopOnly?: boolean;
|
|
93
|
+
/** Funding URLs (optional) */
|
|
94
|
+
fundingUrl?: string | {
|
|
95
|
+
[key: string]: string;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=ManifestTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManifestTypes.d.ts","sourceRoot":"","sources":["../../src/types/ManifestTypes.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Media type constants for Docker and OCI manifests
|
|
2
|
+
export const MEDIATYPE_MANIFEST_V2 = "application/vnd.docker.distribution.manifest.v2+json";
|
|
3
|
+
export const MEDIATYPE_MANIFEST_LIST_V2 = "application/vnd.docker.distribution.manifest.list.v2+json";
|
|
4
|
+
export const MEDIATYPE_OCI_MANIFEST_V1 = "application/vnd.oci.image.manifest.v1+json";
|
|
5
|
+
export const MEDIATYPE_OCI_MANIFEST_INDEX_V1 = "application/vnd.oci.image.index.v1+json";
|
|
6
|
+
export const MEDIATYPE_OBSIDIAN_PLUGIN_CONFIG_V1 = "application/vnd.obsidianmd.plugin-manifest.v1+json";
|
|
7
|
+
export const DEFAULT_USERAGENT = `open-obsidian-plugin-spec/0.1.0`;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry types for Docker/OCI registry operations
|
|
3
|
+
*/
|
|
4
|
+
export interface RegistryIndex {
|
|
5
|
+
name: string;
|
|
6
|
+
official: boolean;
|
|
7
|
+
scheme: "https" | "http";
|
|
8
|
+
}
|
|
9
|
+
export interface RegistryRepo {
|
|
10
|
+
index: RegistryIndex;
|
|
11
|
+
official: boolean;
|
|
12
|
+
remoteName: string;
|
|
13
|
+
localName: string;
|
|
14
|
+
canonicalName: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RegistryImage extends RegistryRepo {
|
|
17
|
+
digest: string | null;
|
|
18
|
+
tag: string | null;
|
|
19
|
+
canonicalRef: string;
|
|
20
|
+
}
|
|
21
|
+
export interface TagList {
|
|
22
|
+
name: string;
|
|
23
|
+
tags: string[];
|
|
24
|
+
child?: string[];
|
|
25
|
+
manifest?: Record<string, {
|
|
26
|
+
imageSizeBytes: string;
|
|
27
|
+
layerId?: string;
|
|
28
|
+
mediaType: string;
|
|
29
|
+
tag: string[];
|
|
30
|
+
timeCreatedMs: string;
|
|
31
|
+
timeUploadedMs: string;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
export interface RegistryError {
|
|
35
|
+
code?: string;
|
|
36
|
+
message: string;
|
|
37
|
+
detail?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface DockerResponse {
|
|
40
|
+
status: number;
|
|
41
|
+
statusText: string;
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
dockerBody(): Promise<ReturnType<Uint8Array["slice"]>>;
|
|
44
|
+
dockerJson(): Promise<unknown>;
|
|
45
|
+
dockerErrors(): Promise<Array<RegistryError>>;
|
|
46
|
+
dockerThrowable(baseMsg: string): Promise<Error>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=RegistryTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegistryTypes.d.ts","sourceRoot":"","sources":["../../src/types/RegistryTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CACf,MAAM,EACN;QACE,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;KACxB,CACF,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACvD,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/B,YAAY,IAAI,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAC9C,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CAClD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request/Response types for HTTP operations
|
|
3
|
+
*/
|
|
4
|
+
/** An alias for Uint8Array<ArrayBuffer> for Typescript 5.7 */
|
|
5
|
+
export type ByteArray = ReturnType<Uint8Array["slice"]>;
|
|
6
|
+
/** Obsidian's requestUrl parameter type */
|
|
7
|
+
export interface RequestUrlParam {
|
|
8
|
+
url: string;
|
|
9
|
+
method?: string;
|
|
10
|
+
contentType?: string;
|
|
11
|
+
body?: string | ArrayBuffer;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
throw?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Obsidian's requestUrl response type */
|
|
16
|
+
export interface RequestUrlResponse {
|
|
17
|
+
status: number;
|
|
18
|
+
headers: Record<string, string>;
|
|
19
|
+
arrayBuffer: ArrayBuffer;
|
|
20
|
+
json: unknown;
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=RequestTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestTypes.d.ts","sourceRoot":"","sources":["../../src/types/RequestTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,8DAA8D;AAC9D,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;AAExD,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,WAAW,EAAE,WAAW,CAAC;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function encodeHex(data: ArrayBuffer): string;
|
|
2
|
+
/**
|
|
3
|
+
* Calculate the 'Docker-Content-Digest' header for the given manifest.
|
|
4
|
+
*
|
|
5
|
+
* @returns {Promise<String>} The docker digest string.
|
|
6
|
+
* @throws {InvalidContentError} if there is a problem parsing the manifest.
|
|
7
|
+
*/
|
|
8
|
+
export declare function digestFromManifestStr(manifestStr: string): Promise<string>;
|
|
9
|
+
//# sourceMappingURL=DigestUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DigestUtils.d.ts","sourceRoot":"","sources":["../../src/utils/DigestUtils.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,UAI1C;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAmBjB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function encodeHex(data) {
|
|
2
|
+
return [...new Uint8Array(data)]
|
|
3
|
+
.map((x) => x.toString(16).padStart(2, "0"))
|
|
4
|
+
.join("");
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Calculate the 'Docker-Content-Digest' header for the given manifest.
|
|
8
|
+
*
|
|
9
|
+
* @returns {Promise<String>} The docker digest string.
|
|
10
|
+
* @throws {InvalidContentError} if there is a problem parsing the manifest.
|
|
11
|
+
*/
|
|
12
|
+
export async function digestFromManifestStr(manifestStr) {
|
|
13
|
+
let manifest;
|
|
14
|
+
try {
|
|
15
|
+
manifest = JSON.parse(manifestStr);
|
|
16
|
+
}
|
|
17
|
+
catch (thrown) {
|
|
18
|
+
const err = thrown;
|
|
19
|
+
throw new Error(`could not parse manifest: ${err.message}\n${manifestStr}`);
|
|
20
|
+
}
|
|
21
|
+
if (manifest.schemaVersion === 1) {
|
|
22
|
+
throw new Error(`schemaVersion 1 is not supported by /x/docker_registry_client.`);
|
|
23
|
+
}
|
|
24
|
+
const hash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(manifestStr));
|
|
25
|
+
return `sha256:${encodeHex(hash)}`;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationUtils.d.ts","sourceRoot":"","sources":["../../src/utils/ValidationUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAK7B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shard-for-obsidian/lib",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Core library for Shard plugin management",
|
|
6
|
+
"author": "Andrew Gillis",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/shard-for-obsidian/shard.git",
|
|
10
|
+
"directory": "packages/shard-lib"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/shard-for-obsidian/shard#readme",
|
|
13
|
+
"bugs": "https://github.com/shard-for-obsidian/shard/issues",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"!dist/**/*.test.*",
|
|
22
|
+
"!dist/**/__tests__"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"provenance": true
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "node esbuild.config.mjs && tsc",
|
|
30
|
+
"clean": "rimraf dist",
|
|
31
|
+
"ts-check": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint .",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"test:ui": "vitest --ui"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"shard",
|
|
39
|
+
"lib",
|
|
40
|
+
"oci",
|
|
41
|
+
"registry",
|
|
42
|
+
"ghcr",
|
|
43
|
+
"container-registry"
|
|
44
|
+
],
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@vitest/ui": "^4.0.18",
|
|
48
|
+
"vitest": "^4.0.18"
|
|
49
|
+
}
|
|
50
|
+
}
|