@voltro/plugin-storage 0.85.0 → 0.87.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/CHANGELOG.md +5987 -0
- package/README.md +77 -0
- package/THIRD-PARTY-NOTICES.md +860 -249
- package/dist/access.js +47 -0
- package/dist/assetRef.js +13 -0
- package/dist/avatar.js +39 -0
- package/dist/byteSecurity.d.ts +3 -0
- package/dist/byteSecurity.js +7 -0
- package/dist/connection.js +99 -0
- package/dist/constraints.js +93 -0
- package/dist/custody.js +132 -0
- package/dist/derivatives.js +30 -0
- package/dist/env.js +162 -0
- package/dist/grant.js +132 -0
- package/dist/index.d.ts +525 -203
- package/dist/index.js +765 -3196
- package/dist/ingest.js +87 -0
- package/dist/ingestPolicy.js +1 -0
- package/dist/metadataError.js +19 -0
- package/dist/objectAbandon.js +16 -0
- package/dist/objectLifecycle.js +243 -0
- package/dist/objectMetadata.js +308 -0
- package/dist/objectWriter.js +87 -0
- package/dist/pathDurability.js +16 -0
- package/dist/physicalReferences.js +54 -0
- package/dist/providers.js +638 -0
- package/dist/referenceCatalogue.js +31 -0
- package/dist/renditionProof.js +82 -0
- package/dist/retainedCapture.js +391 -0
- package/dist/retainedObjects.js +190 -0
- package/dist/rpc.d.ts +3 -15
- package/dist/rpc.js +3 -1
- package/dist/scanners.js +46 -0
- package/dist/server.d.ts +153 -0
- package/dist/server.js +4 -0
- package/dist/service.js +1418 -0
- package/dist/sourceIdentity.js +14 -0
- package/dist/sourcePin.js +35 -0
- package/dist/storageNamespaces.js +80 -0
- package/dist/storageNumbers.js +13 -0
- package/dist/storageObjectNamespaces.js +243 -0
- package/dist/storageReferenceInstances.js +52 -0
- package/dist/storageRequest.js +10 -0
- package/dist/storageRouting.js +46 -0
- package/dist/streamBridge.js +33 -0
- package/dist/table.js +54 -0
- package/dist/transcodeVideo.js +91 -0
- package/dist/transform.js +94 -0
- package/dist/transformCache.js +31 -0
- package/dist/types.d.ts +116 -134
- package/dist/types.js +14 -14
- package/package.json +17 -6
package/dist/grant.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { storageEnv as e } from "./env.js";
|
|
2
|
+
import { Exit as t, Schema as n } from "effect";
|
|
3
|
+
import { createHmac as r, timingSafeEqual as i } from "node:crypto";
|
|
4
|
+
import { StorageAccessPolicySchema as a } from "@voltro/protocol";
|
|
5
|
+
import { noteConfigured as o, noteSigned as s, noteSigningLifetime as c, previousAccepted as l, resolveSessionSecrets as u } from "@voltro/protocol/session";
|
|
6
|
+
//#region src/grant.ts
|
|
7
|
+
var d = () => {
|
|
8
|
+
let t = e.read("VOLTRO_STORAGE_SECRET");
|
|
9
|
+
if (t !== void 0 && t !== "") {
|
|
10
|
+
let n = e.read("VOLTRO_STORAGE_SECRET_PREVIOUS");
|
|
11
|
+
return o("storage", t, n), n === void 0 || n === "" || n === t || !l("storage", n) ? [t] : [t, n];
|
|
12
|
+
}
|
|
13
|
+
let n = u();
|
|
14
|
+
return n.previous === void 0 ? [n.current.secret] : [n.current.secret, n.previous.secret];
|
|
15
|
+
}, f = (t, n) => {
|
|
16
|
+
s(t === e.read("VOLTRO_STORAGE_SECRET") ? "storage" : "session", t, n * 1e3);
|
|
17
|
+
}, p = (t) => {
|
|
18
|
+
c(e.read("VOLTRO_STORAGE_SECRET") ? "storage" : "session", t * 1e3);
|
|
19
|
+
}, m = () => d()[0], h = (e, t, n) => {
|
|
20
|
+
let a = v(t), o = !1;
|
|
21
|
+
for (let t of typeof n == "string" ? [n] : n) {
|
|
22
|
+
if (!t) continue;
|
|
23
|
+
let n = r("sha256", t).update(e).digest();
|
|
24
|
+
a.length === n.length && i(a, n) && (o = !0);
|
|
25
|
+
}
|
|
26
|
+
return o;
|
|
27
|
+
}, g = (e) => typeof e == "string" ? e.length > 0 : e.some((e) => e.length > 0), _ = (e) => (typeof e == "string" ? Buffer.from(e, "utf8") : e).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""), v = (e) => {
|
|
28
|
+
let t = e.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - e.length % 4) % 4);
|
|
29
|
+
return Buffer.from(t, "base64");
|
|
30
|
+
}, y = (e, t, n = m(), i = "/_voltro/storage") => {
|
|
31
|
+
if (!n) throw Error("signGrant: secret must be a non-empty string");
|
|
32
|
+
let a = {
|
|
33
|
+
refId: e,
|
|
34
|
+
audience: i,
|
|
35
|
+
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
36
|
+
}, o = _(JSON.stringify(a)), s = _(r("sha256", n).update(o).digest());
|
|
37
|
+
return f(n, a.exp), `${o}.${s}`;
|
|
38
|
+
}, b = (e, t = d()) => {
|
|
39
|
+
if (!e || !g(t)) return null;
|
|
40
|
+
let n = e.indexOf(".");
|
|
41
|
+
if (n <= 0 || n === e.length - 1) return null;
|
|
42
|
+
let r = e.slice(0, n);
|
|
43
|
+
if (!h(r, e.slice(n + 1), t)) return null;
|
|
44
|
+
try {
|
|
45
|
+
let e = JSON.parse(v(r).toString("utf8"));
|
|
46
|
+
return typeof e.audience != "string" || !e.audience || typeof e.refId != "string" || typeof e.exp != "number" || e.exp <= Math.floor(Date.now() / 1e3) ? null : e;
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}, x = (e) => e.version !== 2 || typeof e.writeScope != "string" || !/^[a-f0-9]{64}$/.test(e.writeScope) || Object.hasOwn(e, "replicaId") || e.issuerReplicaId !== void 0 && (typeof e.issuerReplicaId != "string" || !e.issuerReplicaId.trim()) ? !1 : e.access === void 0 || e.vis === "private" && t.isSuccess(n.decodeUnknownExit(a, { onExcessProperty: "error" })(e.access)), S = (e, t, n = m()) => {
|
|
51
|
+
if (!n) throw Error("signUploadTicket: secret must be a non-empty string");
|
|
52
|
+
let i = {
|
|
53
|
+
...e,
|
|
54
|
+
version: 2,
|
|
55
|
+
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
56
|
+
}, a = _(JSON.stringify(i)), o = _(r("sha256", n).update(`u:${a}`).digest());
|
|
57
|
+
return f(n, i.exp), `${a}.${o}`;
|
|
58
|
+
}, C = (e, t = d()) => {
|
|
59
|
+
if (!e || !g(t)) return null;
|
|
60
|
+
let n = e.indexOf(".");
|
|
61
|
+
if (n <= 0 || n === e.length - 1) return null;
|
|
62
|
+
let r = e.slice(0, n), i = e.slice(n + 1);
|
|
63
|
+
if (!h(`u:${r}`, i, t)) return null;
|
|
64
|
+
try {
|
|
65
|
+
let e = JSON.parse(v(r).toString("utf8"));
|
|
66
|
+
return !x(e) || e.operationId !== void 0 && (typeof e.operationId != "string" || !e.operationId.trim() || e.operationId.length > 200) || typeof e.instance != "string" || !e.instance || typeof e.ct != "string" || typeof e.exp != "number" || typeof e.destination != "string" || !e.destination || e.destination.includes("\0") || /[\uD800-\uDFFF]/u.test(e.destination) || e.vis !== "public" && e.vis !== "private" || e.exp <= Math.floor(Date.now() / 1e3) ? null : e;
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}, w = (e, t, n = m()) => {
|
|
71
|
+
if (!n) throw Error("signFinalizeTicket: secret must be a non-empty string");
|
|
72
|
+
let i = {
|
|
73
|
+
...e,
|
|
74
|
+
version: 2,
|
|
75
|
+
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
76
|
+
}, a = _(JSON.stringify(i)), o = _(r("sha256", n).update(`f:${a}`).digest());
|
|
77
|
+
return f(n, i.exp), `${a}.${o}`;
|
|
78
|
+
}, T = (e, t = d()) => {
|
|
79
|
+
if (!e || !g(t)) return null;
|
|
80
|
+
let n = e.indexOf(".");
|
|
81
|
+
if (n <= 0 || n === e.length - 1) return null;
|
|
82
|
+
let r = e.slice(0, n), i = e.slice(n + 1);
|
|
83
|
+
if (!h(`f:${r}`, i, t)) return null;
|
|
84
|
+
try {
|
|
85
|
+
let e = JSON.parse(v(r).toString("utf8"));
|
|
86
|
+
return !x(e) || typeof e.key != "string" || e.key.length === 0 || typeof e.instance != "string" || !e.instance || typeof e.ct != "string" || typeof e.exp != "number" || typeof e.destination != "string" || !e.destination || e.destination.includes("\0") || /[\uD800-\uDFFF]/u.test(e.destination) || e.vis !== "public" && e.vis !== "private" || e.exp <= Math.floor(Date.now() / 1e3) ? null : e;
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}, E = (e, t, n = m()) => {
|
|
91
|
+
if (!n) throw Error("signResumableTicket: secret must be a non-empty string");
|
|
92
|
+
let i = {
|
|
93
|
+
...e,
|
|
94
|
+
version: 2,
|
|
95
|
+
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
96
|
+
}, a = _(JSON.stringify(i)), o = _(r("sha256", n).update(`r:${a}`).digest());
|
|
97
|
+
return f(n, i.exp), `${a}.${o}`;
|
|
98
|
+
}, D = (e, t = d()) => {
|
|
99
|
+
if (!e || !g(t)) return null;
|
|
100
|
+
let n = e.indexOf(".");
|
|
101
|
+
if (n <= 0 || n === e.length - 1) return null;
|
|
102
|
+
let r = e.slice(0, n), i = e.slice(n + 1);
|
|
103
|
+
if (!h(`r:${r}`, i, t)) return null;
|
|
104
|
+
try {
|
|
105
|
+
let e = JSON.parse(v(r).toString("utf8"));
|
|
106
|
+
return !x(e) || typeof e.id != "string" || e.id.length === 0 || typeof e.size != "number" || e.size < 0 || typeof e.instance != "string" || !e.instance || typeof e.ct != "string" || typeof e.exp != "number" || typeof e.destination != "string" || !e.destination || e.destination.includes("\0") || /[\uD800-\uDFFF]/u.test(e.destination) || e.vis !== "public" && e.vis !== "private" || e.exp <= Math.floor(Date.now() / 1e3) ? null : e;
|
|
107
|
+
} catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}, O = (e, t, n = m()) => {
|
|
111
|
+
if (!n) throw Error("signMultipartTicket: secret must be a non-empty string");
|
|
112
|
+
let i = {
|
|
113
|
+
...e,
|
|
114
|
+
version: 2,
|
|
115
|
+
exp: Math.floor(Date.now() / 1e3) + Math.floor(t)
|
|
116
|
+
}, a = _(JSON.stringify(i)), o = _(r("sha256", n).update(`m:${a}`).digest());
|
|
117
|
+
return f(n, i.exp), `${a}.${o}`;
|
|
118
|
+
}, k = (e, t = d()) => {
|
|
119
|
+
if (!e || !g(t)) return null;
|
|
120
|
+
let n = e.indexOf(".");
|
|
121
|
+
if (n <= 0 || n === e.length - 1) return null;
|
|
122
|
+
let r = e.slice(0, n), i = e.slice(n + 1);
|
|
123
|
+
if (!h(`m:${r}`, i, t)) return null;
|
|
124
|
+
try {
|
|
125
|
+
let e = JSON.parse(v(r).toString("utf8"));
|
|
126
|
+
return !x(e) || typeof e.key != "string" || e.key.length === 0 || typeof e.uploadId != "string" || e.uploadId.length === 0 || typeof e.instance != "string" || !e.instance || typeof e.ct != "string" || typeof e.exp != "number" || typeof e.destination != "string" || !e.destination || e.destination.includes("\0") || /[\uD800-\uDFFF]/u.test(e.destination) || e.vis !== "public" && e.vis !== "private" || e.exp <= Math.floor(Date.now() / 1e3) ? null : e;
|
|
127
|
+
} catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
export { p as declareStorageSigningLifetime, m as resolveStorageSecret, d as resolveStorageSecrets, w as signFinalizeTicket, y as signGrant, O as signMultipartTicket, E as signResumableTicket, S as signUploadTicket, T as verifyFinalizeTicket, b as verifyGrant, k as verifyMultipartTicket, D as verifyResumableTicket, C as verifyUploadTicket };
|