@covia/covia-sdk 1.19.1 → 1.21.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 +8 -0
- package/dist/index.d.mts +108 -14
- package/dist/index.d.ts +108 -14
- package/dist/index.js +201 -48
- package/dist/index.mjs +194 -49
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -163,15 +163,15 @@ var isBig = (n) => typeof n === "bigint";
|
|
|
163
163
|
var isStr = (s) => typeof s === "string";
|
|
164
164
|
var isBytes = (a) => a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
165
165
|
var abytes = (value, length, title = "") => {
|
|
166
|
-
const
|
|
166
|
+
const bytes2 = isBytes(value);
|
|
167
167
|
const len = value?.length;
|
|
168
168
|
const needsLen = length !== void 0;
|
|
169
|
-
if (!
|
|
169
|
+
if (!bytes2 || needsLen && len !== length) {
|
|
170
170
|
const prefix = title && `"${title}" `;
|
|
171
171
|
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
172
|
-
const got =
|
|
172
|
+
const got = bytes2 ? `length=${len}` : `type=${typeof value}`;
|
|
173
173
|
const msg = prefix + "expected Uint8Array" + ofLen + ", got " + got;
|
|
174
|
-
throw
|
|
174
|
+
throw bytes2 ? new RangeError(msg) : new TypeError(msg);
|
|
175
175
|
}
|
|
176
176
|
return value;
|
|
177
177
|
};
|
|
@@ -630,15 +630,15 @@ function isBytes2(a) {
|
|
|
630
630
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
631
631
|
}
|
|
632
632
|
function abytes2(value, length, title = "") {
|
|
633
|
-
const
|
|
633
|
+
const bytes2 = isBytes2(value);
|
|
634
634
|
const len = value?.length;
|
|
635
635
|
const needsLen = length !== void 0;
|
|
636
|
-
if (!
|
|
636
|
+
if (!bytes2 || needsLen) {
|
|
637
637
|
const prefix = title && `"${title}" `;
|
|
638
638
|
const ofLen = "";
|
|
639
|
-
const got =
|
|
639
|
+
const got = bytes2 ? `length=${len}` : `type=${typeof value}`;
|
|
640
640
|
const message = prefix + "expected Uint8Array" + ofLen + ", got " + got;
|
|
641
|
-
if (!
|
|
641
|
+
if (!bytes2)
|
|
642
642
|
throw new TypeError(message);
|
|
643
643
|
throw new RangeError(message);
|
|
644
644
|
}
|
|
@@ -1059,11 +1059,11 @@ function hexToPrivateKey(hex) {
|
|
|
1059
1059
|
if (!/^[0-9a-fA-F]{64}$/.test(cleaned)) {
|
|
1060
1060
|
throw new Error("Invalid Ed25519 private key: expected 64 hex characters (32 bytes)");
|
|
1061
1061
|
}
|
|
1062
|
-
const
|
|
1063
|
-
for (let i = 0; i <
|
|
1064
|
-
|
|
1062
|
+
const bytes2 = new Uint8Array(32);
|
|
1063
|
+
for (let i = 0; i < bytes2.length; i++) {
|
|
1064
|
+
bytes2[i] = parseInt(cleaned.substring(i * 2, i * 2 + 2), 16);
|
|
1065
1065
|
}
|
|
1066
|
-
return
|
|
1066
|
+
return bytes2;
|
|
1067
1067
|
}
|
|
1068
1068
|
|
|
1069
1069
|
// src/crypto/base58.ts
|
|
@@ -1073,13 +1073,13 @@ var ALPHABET_MAP = /* @__PURE__ */ new Map();
|
|
|
1073
1073
|
for (let i = 0; i < ALPHABET.length; i++) {
|
|
1074
1074
|
ALPHABET_MAP.set(ALPHABET[i], i);
|
|
1075
1075
|
}
|
|
1076
|
-
function encode(
|
|
1077
|
-
if (
|
|
1076
|
+
function encode(bytes2) {
|
|
1077
|
+
if (bytes2.length === 0) return "";
|
|
1078
1078
|
let zeros = 0;
|
|
1079
|
-
while (zeros <
|
|
1079
|
+
while (zeros < bytes2.length && bytes2[zeros] === 0) zeros++;
|
|
1080
1080
|
const digits = [];
|
|
1081
|
-
for (let i = zeros; i <
|
|
1082
|
-
let carry =
|
|
1081
|
+
for (let i = zeros; i < bytes2.length; i++) {
|
|
1082
|
+
let carry = bytes2[i];
|
|
1083
1083
|
for (let j = 0; j < digits.length; j++) {
|
|
1084
1084
|
carry += digits[j] << 8;
|
|
1085
1085
|
digits[j] = carry % BASE;
|
|
@@ -1100,24 +1100,24 @@ function decode(str) {
|
|
|
1100
1100
|
if (str.length === 0) return new Uint8Array(0);
|
|
1101
1101
|
let zeros = 0;
|
|
1102
1102
|
while (zeros < str.length && str[zeros] === ALPHABET[0]) zeros++;
|
|
1103
|
-
const
|
|
1103
|
+
const bytes2 = [];
|
|
1104
1104
|
for (let i = zeros; i < str.length; i++) {
|
|
1105
1105
|
const val = ALPHABET_MAP.get(str[i]);
|
|
1106
1106
|
if (val === void 0) throw new Error(`Invalid base58 character: ${str[i]}`);
|
|
1107
1107
|
let carry = val;
|
|
1108
|
-
for (let j = 0; j <
|
|
1109
|
-
carry +=
|
|
1110
|
-
|
|
1108
|
+
for (let j = 0; j < bytes2.length; j++) {
|
|
1109
|
+
carry += bytes2[j] * BASE;
|
|
1110
|
+
bytes2[j] = carry & 255;
|
|
1111
1111
|
carry >>= 8;
|
|
1112
1112
|
}
|
|
1113
1113
|
while (carry > 0) {
|
|
1114
|
-
|
|
1114
|
+
bytes2.push(carry & 255);
|
|
1115
1115
|
carry >>= 8;
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
|
-
const result = new Uint8Array(zeros +
|
|
1118
|
+
const result = new Uint8Array(zeros + bytes2.length);
|
|
1119
1119
|
for (let i = 0; i < zeros; i++) result[i] = 0;
|
|
1120
|
-
for (let i = 0; i <
|
|
1120
|
+
for (let i = 0; i < bytes2.length; i++) result[zeros + i] = bytes2[bytes2.length - 1 - i];
|
|
1121
1121
|
return result;
|
|
1122
1122
|
}
|
|
1123
1123
|
|
|
@@ -1153,7 +1153,16 @@ function base64UrlEncode(data) {
|
|
|
1153
1153
|
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
1154
1154
|
}
|
|
1155
1155
|
function createEdDSAJWT(privateKey, lifetimeSeconds = 300, audience) {
|
|
1156
|
-
const
|
|
1156
|
+
const signingInput = edDSASigningInput(getPublicKey2(privateKey), lifetimeSeconds, audience);
|
|
1157
|
+
const signature = sign(encoder.encode(signingInput), privateKey);
|
|
1158
|
+
return `${signingInput}.${base64UrlEncode(signature)}`;
|
|
1159
|
+
}
|
|
1160
|
+
async function createEdDSAJWTWith(signer, lifetimeSeconds = 300, audience) {
|
|
1161
|
+
const signingInput = edDSASigningInput(signer.publicKey, lifetimeSeconds, audience);
|
|
1162
|
+
const signature = await signer.sign(encoder.encode(signingInput));
|
|
1163
|
+
return `${signingInput}.${base64UrlEncode(signature)}`;
|
|
1164
|
+
}
|
|
1165
|
+
function edDSASigningInput(publicKey, lifetimeSeconds, audience) {
|
|
1157
1166
|
const multikey = encodePublicKey(publicKey);
|
|
1158
1167
|
const did = `did:key:${multikey}`;
|
|
1159
1168
|
const nowSecs = Math.floor(Date.now() / 1e3);
|
|
@@ -1171,18 +1180,95 @@ function createEdDSAJWT(privateKey, lifetimeSeconds = 300, audience) {
|
|
|
1171
1180
|
const payload = JSON.stringify(claims);
|
|
1172
1181
|
const headerB64 = base64UrlEncode(encoder.encode(header));
|
|
1173
1182
|
const payloadB64 = base64UrlEncode(encoder.encode(payload));
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1183
|
+
return `${headerB64}.${payloadB64}`;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// src/crypto/signer.ts
|
|
1187
|
+
var ED25519 = "Ed25519";
|
|
1188
|
+
var PKCS8_ED25519_PREFIX = new Uint8Array([
|
|
1189
|
+
48,
|
|
1190
|
+
46,
|
|
1191
|
+
2,
|
|
1192
|
+
1,
|
|
1193
|
+
0,
|
|
1194
|
+
48,
|
|
1195
|
+
5,
|
|
1196
|
+
6,
|
|
1197
|
+
3,
|
|
1198
|
+
43,
|
|
1199
|
+
101,
|
|
1200
|
+
112,
|
|
1201
|
+
4,
|
|
1202
|
+
34,
|
|
1203
|
+
4,
|
|
1204
|
+
32
|
|
1205
|
+
]);
|
|
1206
|
+
function subtle2() {
|
|
1207
|
+
const s = globalThis.crypto?.subtle;
|
|
1208
|
+
if (!s) {
|
|
1209
|
+
throw new Error("WebCrypto is unavailable: crypto.subtle requires a secure context (HTTPS or localhost)");
|
|
1210
|
+
}
|
|
1211
|
+
return s;
|
|
1212
|
+
}
|
|
1213
|
+
function bytes(data) {
|
|
1214
|
+
return new Uint8Array(data);
|
|
1215
|
+
}
|
|
1216
|
+
function rawKeySigner(privateKey) {
|
|
1217
|
+
const publicKey = getPublicKey2(privateKey);
|
|
1218
|
+
return {
|
|
1219
|
+
publicKey,
|
|
1220
|
+
sign: (data) => Promise.resolve(sign(data, privateKey))
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
async function webCryptoSigner(keyPair) {
|
|
1224
|
+
const publicKey = new Uint8Array(await subtle2().exportKey("raw", keyPair.publicKey));
|
|
1225
|
+
const privateKey = keyPair.privateKey;
|
|
1226
|
+
return {
|
|
1227
|
+
publicKey,
|
|
1228
|
+
sign: async (data) => new Uint8Array(await subtle2().sign(ED25519, privateKey, bytes(data)))
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
async function generateNonExtractableKeyPair() {
|
|
1232
|
+
return subtle2().generateKey(ED25519, false, ["sign", "verify"]);
|
|
1233
|
+
}
|
|
1234
|
+
async function importNonExtractableKey(privateKey) {
|
|
1235
|
+
if (privateKey.length !== 32) {
|
|
1236
|
+
throw new Error("Invalid Ed25519 private key: expected 32 bytes");
|
|
1237
|
+
}
|
|
1238
|
+
const pkcs8 = new Uint8Array(PKCS8_ED25519_PREFIX.length + 32);
|
|
1239
|
+
pkcs8.set(PKCS8_ED25519_PREFIX, 0);
|
|
1240
|
+
pkcs8.set(privateKey, PKCS8_ED25519_PREFIX.length);
|
|
1241
|
+
try {
|
|
1242
|
+
const s = subtle2();
|
|
1243
|
+
const [priv, pub] = await Promise.all([
|
|
1244
|
+
s.importKey("pkcs8", pkcs8, ED25519, false, ["sign"]),
|
|
1245
|
+
s.importKey("raw", bytes(getPublicKey2(privateKey)), ED25519, true, ["verify"])
|
|
1246
|
+
]);
|
|
1247
|
+
return { privateKey: priv, publicKey: pub };
|
|
1248
|
+
} finally {
|
|
1249
|
+
pkcs8.fill(0);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
var supported;
|
|
1253
|
+
function isWebCryptoEd25519Supported() {
|
|
1254
|
+
supported ?? (supported = (async () => {
|
|
1255
|
+
try {
|
|
1256
|
+
const kp = await generateNonExtractableKeyPair();
|
|
1257
|
+
await subtle2().sign(ED25519, kp.privateKey, new Uint8Array(1));
|
|
1258
|
+
return true;
|
|
1259
|
+
} catch {
|
|
1260
|
+
return false;
|
|
1261
|
+
}
|
|
1262
|
+
})());
|
|
1263
|
+
return supported;
|
|
1178
1264
|
}
|
|
1179
1265
|
|
|
1180
1266
|
// src/Credentials.ts
|
|
1181
1267
|
function base64Encode(text) {
|
|
1182
|
-
const
|
|
1268
|
+
const bytes2 = new TextEncoder().encode(text);
|
|
1183
1269
|
let binary = "";
|
|
1184
|
-
for (let i = 0; i <
|
|
1185
|
-
binary += String.fromCharCode(
|
|
1270
|
+
for (let i = 0; i < bytes2.length; i++) {
|
|
1271
|
+
binary += String.fromCharCode(bytes2[i]);
|
|
1186
1272
|
}
|
|
1187
1273
|
return btoa(binary);
|
|
1188
1274
|
}
|
|
@@ -1214,18 +1300,29 @@ var BasicAuth = class extends Auth {
|
|
|
1214
1300
|
};
|
|
1215
1301
|
var Ed25519Auth = class _Ed25519Auth extends Auth {
|
|
1216
1302
|
/**
|
|
1217
|
-
* @param
|
|
1303
|
+
* @param key - 32-byte Ed25519 private key, or an {@link Ed25519Signer}
|
|
1218
1304
|
* @param tokenLifetimeSeconds - JWT lifetime in seconds (default 300 = 5 min)
|
|
1219
1305
|
*/
|
|
1220
|
-
constructor(
|
|
1306
|
+
constructor(key, tokenLifetimeSeconds = 300) {
|
|
1221
1307
|
super();
|
|
1222
|
-
|
|
1223
|
-
|
|
1308
|
+
if (isSigner(key)) {
|
|
1309
|
+
this._signer = key;
|
|
1310
|
+
} else {
|
|
1311
|
+
this._privateKey = key;
|
|
1312
|
+
this._signer = rawKeySigner(key);
|
|
1313
|
+
}
|
|
1314
|
+
this._publicKey = this._signer.publicKey;
|
|
1224
1315
|
this._did = didFromPublicKey(this._publicKey);
|
|
1225
1316
|
this._lifetime = tokenLifetimeSeconds;
|
|
1226
1317
|
}
|
|
1227
1318
|
apply(headers, audience) {
|
|
1228
|
-
|
|
1319
|
+
if (this._privateKey) {
|
|
1320
|
+
headers["Authorization"] = `Bearer ${this.identityToken(audience)}`;
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
return this.mintIdentityToken(audience).then((token) => {
|
|
1324
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
1325
|
+
});
|
|
1229
1326
|
}
|
|
1230
1327
|
/**
|
|
1231
1328
|
* Mint a bearer-usable identity JWT for this key — the same token
|
|
@@ -1238,17 +1335,37 @@ var Ed25519Auth = class _Ed25519Auth extends Auth {
|
|
|
1238
1335
|
* at any venue that accepts the caller's DID, so minting one is refused
|
|
1239
1336
|
* rather than silently weakened.
|
|
1240
1337
|
*
|
|
1338
|
+
* Raw-key instances only: a signer-backed instance signs asynchronously,
|
|
1339
|
+
* so use {@link mintIdentityToken}, which works for both.
|
|
1340
|
+
*
|
|
1241
1341
|
* @param audience - The venue DID the token is bound to (`aud` claim).
|
|
1242
1342
|
* @param lifetimeSeconds - Token lifetime; defaults to this instance's.
|
|
1243
1343
|
*/
|
|
1244
1344
|
identityToken(audience, lifetimeSeconds) {
|
|
1345
|
+
const aud = this.resolveAudience(audience);
|
|
1346
|
+
if (!this._privateKey) {
|
|
1347
|
+
throw new CoviaError(
|
|
1348
|
+
"Ed25519Auth.identityToken() needs a raw private key; this instance signs through an Ed25519Signer, so use the async mintIdentityToken() instead."
|
|
1349
|
+
);
|
|
1350
|
+
}
|
|
1351
|
+
return createEdDSAJWT(this._privateKey, lifetimeSeconds ?? this._lifetime, aud);
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Async {@link identityToken} that works for raw-key and signer-backed
|
|
1355
|
+
* instances alike. Same token, same audience rules.
|
|
1356
|
+
*/
|
|
1357
|
+
async mintIdentityToken(audience, lifetimeSeconds) {
|
|
1358
|
+
const aud = this.resolveAudience(audience);
|
|
1359
|
+
return createEdDSAJWTWith(this._signer, lifetimeSeconds ?? this._lifetime, aud);
|
|
1360
|
+
}
|
|
1361
|
+
resolveAudience(audience) {
|
|
1245
1362
|
const aud = this._audience ?? (audience || void 0);
|
|
1246
1363
|
if (!aud) {
|
|
1247
1364
|
throw new CoviaError(
|
|
1248
1365
|
"Ed25519Auth requires a venue audience to bind the token to: connect via Grid.connect()/Venue.connect() so the venue DID is known, or pin auth.audience explicitly."
|
|
1249
1366
|
);
|
|
1250
1367
|
}
|
|
1251
|
-
return
|
|
1368
|
+
return aud;
|
|
1252
1369
|
}
|
|
1253
1370
|
/** The caller's DID derived from the public key. */
|
|
1254
1371
|
getDID() {
|
|
@@ -1277,7 +1394,17 @@ var Ed25519Auth = class _Ed25519Auth extends Auth {
|
|
|
1277
1394
|
static fromHex(privateKeyHex, tokenLifetimeSeconds = 300) {
|
|
1278
1395
|
return new _Ed25519Auth(hexToPrivateKey(privateKeyHex), tokenLifetimeSeconds);
|
|
1279
1396
|
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Create from an {@link Ed25519Signer}, e.g. `await webCryptoSigner(keyPair)`
|
|
1399
|
+
* over a non-extractable WebCrypto key. Requests sign asynchronously.
|
|
1400
|
+
*/
|
|
1401
|
+
static fromSigner(signer, tokenLifetimeSeconds = 300) {
|
|
1402
|
+
return new _Ed25519Auth(signer, tokenLifetimeSeconds);
|
|
1403
|
+
}
|
|
1280
1404
|
};
|
|
1405
|
+
function isSigner(key) {
|
|
1406
|
+
return !ArrayBuffer.isView(key) && typeof key.sign === "function";
|
|
1407
|
+
}
|
|
1281
1408
|
var KeyPairAuth = Ed25519Auth;
|
|
1282
1409
|
var CredentialsHTTP = class {
|
|
1283
1410
|
constructor(venueId, apiKey, userId) {
|
|
@@ -1701,7 +1828,7 @@ var AdapterManager = class {
|
|
|
1701
1828
|
};
|
|
1702
1829
|
|
|
1703
1830
|
// src/VenueTransport.ts
|
|
1704
|
-
function requestOptions(venue, options) {
|
|
1831
|
+
async function requestOptions(venue, options) {
|
|
1705
1832
|
const {
|
|
1706
1833
|
contentType,
|
|
1707
1834
|
headers: suppliedHeaders = {},
|
|
@@ -1712,19 +1839,19 @@ function requestOptions(venue, options) {
|
|
|
1712
1839
|
if (effectiveContentType && headers["Content-Type"] === void 0) {
|
|
1713
1840
|
headers["Content-Type"] = effectiveContentType;
|
|
1714
1841
|
}
|
|
1715
|
-
venue.auth.apply(headers, venue.venueId);
|
|
1842
|
+
await venue.auth.apply(headers, venue.venueId);
|
|
1716
1843
|
return { ...request, headers };
|
|
1717
1844
|
}
|
|
1718
|
-
function venueJson(venue, path, options = {}) {
|
|
1845
|
+
async function venueJson(venue, path, options = {}) {
|
|
1719
1846
|
return fetchWithError(
|
|
1720
1847
|
`${venue.baseUrl}${path}`,
|
|
1721
|
-
requestOptions(venue, options)
|
|
1848
|
+
await requestOptions(venue, options)
|
|
1722
1849
|
);
|
|
1723
1850
|
}
|
|
1724
|
-
function venueStream(venue, path, options = {}) {
|
|
1851
|
+
async function venueStream(venue, path, options = {}) {
|
|
1725
1852
|
return fetchStreamWithError(
|
|
1726
1853
|
`${venue.baseUrl}${path}`,
|
|
1727
|
-
requestOptions(venue, options)
|
|
1854
|
+
await requestOptions(venue, options)
|
|
1728
1855
|
);
|
|
1729
1856
|
}
|
|
1730
1857
|
|
|
@@ -2529,6 +2656,9 @@ var AssetManager = class {
|
|
|
2529
2656
|
if (options.expand !== void 0) {
|
|
2530
2657
|
params.set("expand", options.expand);
|
|
2531
2658
|
}
|
|
2659
|
+
if (options.kind !== void 0) {
|
|
2660
|
+
params.set("kind", options.kind);
|
|
2661
|
+
}
|
|
2532
2662
|
return venueJson(
|
|
2533
2663
|
this.venue,
|
|
2534
2664
|
`/api/v1/assets?${params.toString()}`,
|
|
@@ -4065,7 +4195,17 @@ function didFor(privateKey) {
|
|
|
4065
4195
|
return `did:key:${encodePublicKey(getPublicKey2(privateKey))}`;
|
|
4066
4196
|
}
|
|
4067
4197
|
function createUCANJWT(privateKey, audienceDID, att, lifetimeSeconds, proofs = []) {
|
|
4068
|
-
const
|
|
4198
|
+
const signingInput = ucanSigningInput(getPublicKey2(privateKey), audienceDID, att, lifetimeSeconds, proofs);
|
|
4199
|
+
const signature = sign(encoder2.encode(signingInput), privateKey);
|
|
4200
|
+
return `${signingInput}.${base64UrlEncode(signature)}`;
|
|
4201
|
+
}
|
|
4202
|
+
async function createUCANJWTWith(signer, audienceDID, att, lifetimeSeconds, proofs = []) {
|
|
4203
|
+
const signingInput = ucanSigningInput(signer.publicKey, audienceDID, att, lifetimeSeconds, proofs);
|
|
4204
|
+
const signature = await signer.sign(encoder2.encode(signingInput));
|
|
4205
|
+
return `${signingInput}.${base64UrlEncode(signature)}`;
|
|
4206
|
+
}
|
|
4207
|
+
function ucanSigningInput(publicKey, audienceDID, att, lifetimeSeconds, proofs) {
|
|
4208
|
+
const multikey = encodePublicKey(publicKey);
|
|
4069
4209
|
const nowSecs = Math.floor(Date.now() / 1e3);
|
|
4070
4210
|
const header = JSON.stringify({ alg: "EdDSA", typ: "JWT", kid: multikey });
|
|
4071
4211
|
const claims = {
|
|
@@ -4081,9 +4221,7 @@ function createUCANJWT(privateKey, audienceDID, att, lifetimeSeconds, proofs = [
|
|
|
4081
4221
|
// CVMDouble the venue's UcanJwtValidator rejects outright (covia-sdk#46).
|
|
4082
4222
|
exp: lifetimeSeconds === null ? null : Math.floor(nowSecs + lifetimeSeconds)
|
|
4083
4223
|
};
|
|
4084
|
-
|
|
4085
|
-
const signature = sign(encoder2.encode(signingInput), privateKey);
|
|
4086
|
-
return `${signingInput}.${base64UrlEncode(signature)}`;
|
|
4224
|
+
return `${base64UrlEncode(encoder2.encode(header))}.${base64UrlEncode(encoder2.encode(JSON.stringify(claims)))}`;
|
|
4087
4225
|
}
|
|
4088
4226
|
function identityToken(privateKey, venueDID, lifetimeSeconds = 300) {
|
|
4089
4227
|
return createUCANJWT(privateKey, venueDID, [], lifetimeSeconds);
|
|
@@ -4091,14 +4229,21 @@ function identityToken(privateKey, venueDID, lifetimeSeconds = 300) {
|
|
|
4091
4229
|
function grant(ownerPrivateKey, audienceDID, withResource, can, lifetimeSeconds) {
|
|
4092
4230
|
return createUCANJWT(ownerPrivateKey, audienceDID, [{ with: withResource, can }], lifetimeSeconds);
|
|
4093
4231
|
}
|
|
4232
|
+
function grantWith(ownerSigner, audienceDID, withResource, can, lifetimeSeconds) {
|
|
4233
|
+
return createUCANJWTWith(ownerSigner, audienceDID, [{ with: withResource, can }], lifetimeSeconds);
|
|
4234
|
+
}
|
|
4094
4235
|
function relayDelegation(privateKey, venueDID, lifetimeSeconds, caps = []) {
|
|
4095
4236
|
const att = [{ with: didFor(privateKey), can: VENUE_RELAY }, ...caps];
|
|
4096
4237
|
return createUCANJWT(privateKey, venueDID, att, lifetimeSeconds);
|
|
4097
4238
|
}
|
|
4239
|
+
function relayDelegationWith(signer, venueDID, lifetimeSeconds, caps = []) {
|
|
4240
|
+
const att = [{ with: didFromPublicKey(signer.publicKey), can: VENUE_RELAY }, ...caps];
|
|
4241
|
+
return createUCANJWTWith(signer, venueDID, att, lifetimeSeconds);
|
|
4242
|
+
}
|
|
4098
4243
|
/*! Bundled license information:
|
|
4099
4244
|
|
|
4100
4245
|
@noble/ed25519/index.js:
|
|
4101
4246
|
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
4102
4247
|
*/
|
|
4103
4248
|
|
|
4104
|
-
export { A2AManager, AdapterManager, Agent, AgentManager, AgentSessionNotFoundError, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BasicAuth, BearerAuth, ChatSession, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DLFSManager, DataAsset, Ed25519Auth, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, MCPError, MCPManager, MemoryManager, Namespace, NoAuth, NotFoundError, Operation, OperationManager, RateLimitError, RunStatus, ScopedWorkspace, SecretManager, SkillManager, UCANManager, UnsupportedVenueFeatureError, UserManager, VENUE_RELAY, Venue, VenueIdentityChangedError, WorkspaceManager, assetHash, createSSEEvent, createUCANJWT, decodePublicKey, didFor, didFromPublicKey, didMethod, didUrl, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getAssetMetadataStore, getParsedAssetId, grant, hexToPrivateKey, identityToken, isDid, isJobComplete, isJobFinished, isJobPaused, logger, parseDidUrl, parseRetryAfterMs, parseSSEStream, privateKeyToHex, relayDelegation, retryDelayMs, setAssetMetadataStore, venueBaseUrlCandidates };
|
|
4249
|
+
export { A2AManager, AdapterManager, Agent, AgentManager, AgentSessionNotFoundError, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BasicAuth, BearerAuth, ChatSession, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DLFSManager, DataAsset, Ed25519Auth, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, MCPError, MCPManager, MemoryManager, Namespace, NoAuth, NotFoundError, Operation, OperationManager, RateLimitError, RunStatus, ScopedWorkspace, SecretManager, SkillManager, UCANManager, UnsupportedVenueFeatureError, UserManager, VENUE_RELAY, Venue, VenueIdentityChangedError, WorkspaceManager, assetHash, createSSEEvent, createUCANJWT, createUCANJWTWith, decodePublicKey, didFor, didFromPublicKey, didMethod, didUrl, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, generateNonExtractableKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getAssetMetadataStore, getParsedAssetId, grant, grantWith, hexToPrivateKey, identityToken, importNonExtractableKey, isDid, isJobComplete, isJobFinished, isJobPaused, isWebCryptoEd25519Supported, logger, parseDidUrl, parseRetryAfterMs, parseSSEStream, privateKeyToHex, rawKeySigner, relayDelegation, relayDelegationWith, retryDelayMs, setAssetMetadataStore, venueBaseUrlCandidates, webCryptoSigner };
|