@covia/covia-sdk 1.9.0 → 1.9.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.mts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +18 -2
- package/dist/index.mjs +18 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -262,6 +262,21 @@ declare class Ed25519Auth extends Auth {
|
|
|
262
262
|
*/
|
|
263
263
|
constructor(privateKey: Uint8Array, tokenLifetimeSeconds?: number);
|
|
264
264
|
apply(headers: Record<string, string>, audience?: string): void;
|
|
265
|
+
/**
|
|
266
|
+
* Mint a bearer-usable identity JWT for this key — the same token
|
|
267
|
+
* {@link apply} attaches to every request, exposed for callers that need
|
|
268
|
+
* to present this identity elsewhere (CLI tools, curl, another client:
|
|
269
|
+
* `Authorization: Bearer <token>`).
|
|
270
|
+
*
|
|
271
|
+
* An explicitly-pinned {@link audience} wins; otherwise the JWT `aud` is
|
|
272
|
+
* bound to the venue DID given here. A token with no `aud` is replayable
|
|
273
|
+
* at any venue that accepts the caller's DID, so minting one is refused
|
|
274
|
+
* rather than silently weakened.
|
|
275
|
+
*
|
|
276
|
+
* @param audience - The venue DID the token is bound to (`aud` claim).
|
|
277
|
+
* @param lifetimeSeconds - Token lifetime; defaults to this instance's.
|
|
278
|
+
*/
|
|
279
|
+
identityToken(audience?: string, lifetimeSeconds?: number): string;
|
|
265
280
|
/** The caller's DID derived from the public key. */
|
|
266
281
|
getDID(): string;
|
|
267
282
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -262,6 +262,21 @@ declare class Ed25519Auth extends Auth {
|
|
|
262
262
|
*/
|
|
263
263
|
constructor(privateKey: Uint8Array, tokenLifetimeSeconds?: number);
|
|
264
264
|
apply(headers: Record<string, string>, audience?: string): void;
|
|
265
|
+
/**
|
|
266
|
+
* Mint a bearer-usable identity JWT for this key — the same token
|
|
267
|
+
* {@link apply} attaches to every request, exposed for callers that need
|
|
268
|
+
* to present this identity elsewhere (CLI tools, curl, another client:
|
|
269
|
+
* `Authorization: Bearer <token>`).
|
|
270
|
+
*
|
|
271
|
+
* An explicitly-pinned {@link audience} wins; otherwise the JWT `aud` is
|
|
272
|
+
* bound to the venue DID given here. A token with no `aud` is replayable
|
|
273
|
+
* at any venue that accepts the caller's DID, so minting one is refused
|
|
274
|
+
* rather than silently weakened.
|
|
275
|
+
*
|
|
276
|
+
* @param audience - The venue DID the token is bound to (`aud` claim).
|
|
277
|
+
* @param lifetimeSeconds - Token lifetime; defaults to this instance's.
|
|
278
|
+
*/
|
|
279
|
+
identityToken(audience?: string, lifetimeSeconds?: number): string;
|
|
265
280
|
/** The caller's DID derived from the public key. */
|
|
266
281
|
getDID(): string;
|
|
267
282
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1217,14 +1217,30 @@ var Ed25519Auth = class _Ed25519Auth extends Auth {
|
|
|
1217
1217
|
this._lifetime = tokenLifetimeSeconds;
|
|
1218
1218
|
}
|
|
1219
1219
|
apply(headers, audience) {
|
|
1220
|
+
headers["Authorization"] = `Bearer ${this.identityToken(audience)}`;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Mint a bearer-usable identity JWT for this key — the same token
|
|
1224
|
+
* {@link apply} attaches to every request, exposed for callers that need
|
|
1225
|
+
* to present this identity elsewhere (CLI tools, curl, another client:
|
|
1226
|
+
* `Authorization: Bearer <token>`).
|
|
1227
|
+
*
|
|
1228
|
+
* An explicitly-pinned {@link audience} wins; otherwise the JWT `aud` is
|
|
1229
|
+
* bound to the venue DID given here. A token with no `aud` is replayable
|
|
1230
|
+
* at any venue that accepts the caller's DID, so minting one is refused
|
|
1231
|
+
* rather than silently weakened.
|
|
1232
|
+
*
|
|
1233
|
+
* @param audience - The venue DID the token is bound to (`aud` claim).
|
|
1234
|
+
* @param lifetimeSeconds - Token lifetime; defaults to this instance's.
|
|
1235
|
+
*/
|
|
1236
|
+
identityToken(audience, lifetimeSeconds) {
|
|
1220
1237
|
const aud = this._audience ?? (audience || void 0);
|
|
1221
1238
|
if (!aud) {
|
|
1222
1239
|
throw new CoviaError(
|
|
1223
1240
|
"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."
|
|
1224
1241
|
);
|
|
1225
1242
|
}
|
|
1226
|
-
|
|
1227
|
-
headers["Authorization"] = `Bearer ${jwt}`;
|
|
1243
|
+
return createEdDSAJWT(this._privateKey, lifetimeSeconds ?? this._lifetime, aud);
|
|
1228
1244
|
}
|
|
1229
1245
|
/** The caller's DID derived from the public key. */
|
|
1230
1246
|
getDID() {
|
package/dist/index.mjs
CHANGED
|
@@ -1215,14 +1215,30 @@ var Ed25519Auth = class _Ed25519Auth extends Auth {
|
|
|
1215
1215
|
this._lifetime = tokenLifetimeSeconds;
|
|
1216
1216
|
}
|
|
1217
1217
|
apply(headers, audience) {
|
|
1218
|
+
headers["Authorization"] = `Bearer ${this.identityToken(audience)}`;
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Mint a bearer-usable identity JWT for this key — the same token
|
|
1222
|
+
* {@link apply} attaches to every request, exposed for callers that need
|
|
1223
|
+
* to present this identity elsewhere (CLI tools, curl, another client:
|
|
1224
|
+
* `Authorization: Bearer <token>`).
|
|
1225
|
+
*
|
|
1226
|
+
* An explicitly-pinned {@link audience} wins; otherwise the JWT `aud` is
|
|
1227
|
+
* bound to the venue DID given here. A token with no `aud` is replayable
|
|
1228
|
+
* at any venue that accepts the caller's DID, so minting one is refused
|
|
1229
|
+
* rather than silently weakened.
|
|
1230
|
+
*
|
|
1231
|
+
* @param audience - The venue DID the token is bound to (`aud` claim).
|
|
1232
|
+
* @param lifetimeSeconds - Token lifetime; defaults to this instance's.
|
|
1233
|
+
*/
|
|
1234
|
+
identityToken(audience, lifetimeSeconds) {
|
|
1218
1235
|
const aud = this._audience ?? (audience || void 0);
|
|
1219
1236
|
if (!aud) {
|
|
1220
1237
|
throw new CoviaError(
|
|
1221
1238
|
"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."
|
|
1222
1239
|
);
|
|
1223
1240
|
}
|
|
1224
|
-
|
|
1225
|
-
headers["Authorization"] = `Bearer ${jwt}`;
|
|
1241
|
+
return createEdDSAJWT(this._privateKey, lifetimeSeconds ?? this._lifetime, aud);
|
|
1226
1242
|
}
|
|
1227
1243
|
/** The caller's DID derived from the public key. */
|
|
1228
1244
|
getDID() {
|