@naylence/runtime 0.3.5-test.922 → 0.3.5-test.923
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/browser/index.cjs +145 -144
- package/dist/browser/index.mjs +145 -145
- package/dist/cjs/naylence/fame/security/index.js +3 -1
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/security/index.js +1 -0
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +145 -144
- package/dist/node/index.mjs +145 -145
- package/dist/node/node.cjs +144 -143
- package/dist/node/node.mjs +144 -144
- package/dist/types/naylence/fame/security/index.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
var core = require('@naylence/core');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
var factory = require('@naylence/factory');
|
|
6
|
+
var ed25519 = require('@noble/ed25519');
|
|
7
|
+
var sha2_js = require('@noble/hashes/sha2.js');
|
|
6
8
|
var chacha_js = require('@noble/ciphers/chacha.js');
|
|
7
9
|
var ed25519_js = require('@noble/curves/ed25519.js');
|
|
8
10
|
var hkdf_js = require('@noble/hashes/hkdf.js');
|
|
9
|
-
var sha2_js = require('@noble/hashes/sha2.js');
|
|
10
11
|
var utils_js = require('@noble/hashes/utils.js');
|
|
11
12
|
var yaml = require('yaml');
|
|
12
13
|
var fastify = require('fastify');
|
|
13
14
|
var websocketPlugin = require('@fastify/websocket');
|
|
14
|
-
var ed25519 = require('@noble/ed25519');
|
|
15
15
|
|
|
16
16
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
17
17
|
// --- ENV SHIM (runs once in browser) ---
|
|
@@ -98,12 +98,12 @@ installProcessEnvShim();
|
|
|
98
98
|
// --- END ENV SHIM ---
|
|
99
99
|
|
|
100
100
|
// This file is auto-generated during build - do not edit manually
|
|
101
|
-
// Generated from package.json version: 0.3.5-test.
|
|
101
|
+
// Generated from package.json version: 0.3.5-test.923
|
|
102
102
|
/**
|
|
103
103
|
* The package version, injected at build time.
|
|
104
104
|
* @internal
|
|
105
105
|
*/
|
|
106
|
-
const VERSION = '0.3.5-test.
|
|
106
|
+
const VERSION = '0.3.5-test.923';
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -25350,6 +25350,146 @@ function encodeUtf8(value) {
|
|
|
25350
25350
|
throw new Error('No UTF-8 encoder available in this environment');
|
|
25351
25351
|
}
|
|
25352
25352
|
|
|
25353
|
+
if (!ed25519.hashes.sha512) {
|
|
25354
|
+
ed25519.hashes.sha512 = (message) => sha2_js.sha512(message);
|
|
25355
|
+
}
|
|
25356
|
+
function normalizeSignerOptions(options) {
|
|
25357
|
+
if (!options || typeof options !== 'object') {
|
|
25358
|
+
return {};
|
|
25359
|
+
}
|
|
25360
|
+
const candidate = options;
|
|
25361
|
+
const result = {
|
|
25362
|
+
...options,
|
|
25363
|
+
};
|
|
25364
|
+
const cryptoProvider = resolveAlias(candidate, ['cryptoProvider', 'crypto_provider']);
|
|
25365
|
+
if (cryptoProvider !== undefined) {
|
|
25366
|
+
result.cryptoProvider = cryptoProvider ?? null;
|
|
25367
|
+
}
|
|
25368
|
+
const signingConfig = resolveAlias(candidate, ['signingConfig', 'signing_config']);
|
|
25369
|
+
if (signingConfig !== undefined) {
|
|
25370
|
+
result.signingConfig = signingConfig;
|
|
25371
|
+
}
|
|
25372
|
+
const privateKeyPem = resolveAlias(candidate, [
|
|
25373
|
+
'privateKeyPem',
|
|
25374
|
+
'private_key_pem',
|
|
25375
|
+
]);
|
|
25376
|
+
if (privateKeyPem !== undefined) {
|
|
25377
|
+
result.privateKeyPem = privateKeyPem;
|
|
25378
|
+
}
|
|
25379
|
+
const keyId = resolveAlias(candidate, [
|
|
25380
|
+
'keyId',
|
|
25381
|
+
'key_id',
|
|
25382
|
+
]);
|
|
25383
|
+
if (keyId !== undefined) {
|
|
25384
|
+
result.keyId = keyId;
|
|
25385
|
+
}
|
|
25386
|
+
return result;
|
|
25387
|
+
}
|
|
25388
|
+
class EdDSAEnvelopeSigner {
|
|
25389
|
+
constructor(options = {}) {
|
|
25390
|
+
const normalized = normalizeSignerOptions(options);
|
|
25391
|
+
const provider = normalized.cryptoProvider ?? null;
|
|
25392
|
+
if (!provider) {
|
|
25393
|
+
throw new Error('No crypto provider is configured for signing');
|
|
25394
|
+
}
|
|
25395
|
+
this.crypto = provider;
|
|
25396
|
+
const signingConfigOption = normalized.signingConfig;
|
|
25397
|
+
if (signingConfigOption instanceof SigningConfig) {
|
|
25398
|
+
this.signingConfig = signingConfigOption;
|
|
25399
|
+
}
|
|
25400
|
+
else if (signingConfigOption) {
|
|
25401
|
+
this.signingConfig = new SigningConfig(signingConfigOption);
|
|
25402
|
+
}
|
|
25403
|
+
else {
|
|
25404
|
+
this.signingConfig = new SigningConfig();
|
|
25405
|
+
}
|
|
25406
|
+
this.explicitPrivateKey = normalized.privateKeyPem;
|
|
25407
|
+
this.explicitKeyId = normalized.keyId;
|
|
25408
|
+
}
|
|
25409
|
+
signEnvelope(envelope, { physicalPath }) {
|
|
25410
|
+
if (!envelope.sid) {
|
|
25411
|
+
throw new Error('Envelope missing sid');
|
|
25412
|
+
}
|
|
25413
|
+
const frame = envelope.frame;
|
|
25414
|
+
if (frame.type === 'Data') {
|
|
25415
|
+
const dataFrame = frame;
|
|
25416
|
+
if (!dataFrame.pd) {
|
|
25417
|
+
const payload = dataFrame.payload ?? '';
|
|
25418
|
+
const payloadString = payload === '' ? '' : canonicalJson(payload);
|
|
25419
|
+
dataFrame.pd = secureDigest(payloadString);
|
|
25420
|
+
}
|
|
25421
|
+
}
|
|
25422
|
+
const digest = frameDigest(frame);
|
|
25423
|
+
const immutable = canonicalJson(immutableHeaders(envelope));
|
|
25424
|
+
const sidDigest = secureDigest(physicalPath);
|
|
25425
|
+
const tbs = new Uint8Array(encodeUtf8(sidDigest).length +
|
|
25426
|
+
1 +
|
|
25427
|
+
encodeUtf8(immutable).length +
|
|
25428
|
+
1 +
|
|
25429
|
+
encodeUtf8(digest).length);
|
|
25430
|
+
const sidBytes = encodeUtf8(sidDigest);
|
|
25431
|
+
const immBytes = encodeUtf8(immutable);
|
|
25432
|
+
const digBytes = encodeUtf8(digest);
|
|
25433
|
+
let offset = 0;
|
|
25434
|
+
tbs.set(sidBytes, offset);
|
|
25435
|
+
offset += sidBytes.length;
|
|
25436
|
+
tbs[offset] = 0x1f;
|
|
25437
|
+
offset += 1;
|
|
25438
|
+
tbs.set(immBytes, offset);
|
|
25439
|
+
offset += immBytes.length;
|
|
25440
|
+
tbs[offset] = 0x1f;
|
|
25441
|
+
offset += 1;
|
|
25442
|
+
tbs.set(digBytes, offset);
|
|
25443
|
+
const privateKey = this.loadPrivateKey();
|
|
25444
|
+
const signatureBytes = ed25519.sign(tbs, privateKey);
|
|
25445
|
+
const signature = urlsafeBase64Encode(signatureBytes);
|
|
25446
|
+
const kid = this.determineKeyId();
|
|
25447
|
+
const signatureHeader = {
|
|
25448
|
+
kid,
|
|
25449
|
+
val: signature,
|
|
25450
|
+
alg: 'EdDSA',
|
|
25451
|
+
};
|
|
25452
|
+
const secHeader = envelope.sec ?? {};
|
|
25453
|
+
secHeader.sig = signatureHeader;
|
|
25454
|
+
envelope.sec = secHeader;
|
|
25455
|
+
return envelope;
|
|
25456
|
+
}
|
|
25457
|
+
loadPrivateKey() {
|
|
25458
|
+
const pem = this.explicitPrivateKey ??
|
|
25459
|
+
readStringProperty(this.crypto, 'signingPrivatePem', 'signing_private_pem');
|
|
25460
|
+
if (!pem) {
|
|
25461
|
+
throw new Error('Crypto provider does not expose a signing private key');
|
|
25462
|
+
}
|
|
25463
|
+
return parseEd25519PrivateKey(pem);
|
|
25464
|
+
}
|
|
25465
|
+
determineKeyId() {
|
|
25466
|
+
if (this.explicitKeyId) {
|
|
25467
|
+
return this.explicitKeyId;
|
|
25468
|
+
}
|
|
25469
|
+
if (this.signingConfig.signingMaterial === core.SigningMaterial.X509_CHAIN) {
|
|
25470
|
+
const certificateProvider = this
|
|
25471
|
+
.crypto;
|
|
25472
|
+
const jwk = certificateProvider.nodeJwk?.();
|
|
25473
|
+
if (jwk && typeof jwk === 'object' && 'kid' in jwk && 'x5c' in jwk) {
|
|
25474
|
+
const kid = jwk.kid;
|
|
25475
|
+
if (typeof kid === 'string' && kid.length > 0) {
|
|
25476
|
+
return kid;
|
|
25477
|
+
}
|
|
25478
|
+
}
|
|
25479
|
+
}
|
|
25480
|
+
const fallback = readStringProperty(this.crypto, 'signatureKeyId', 'signature_key_id');
|
|
25481
|
+
if (!fallback) {
|
|
25482
|
+
throw new Error('Crypto provider does not expose a signature key id');
|
|
25483
|
+
}
|
|
25484
|
+
return fallback;
|
|
25485
|
+
}
|
|
25486
|
+
}
|
|
25487
|
+
|
|
25488
|
+
var eddsaEnvelopeSigner = /*#__PURE__*/Object.freeze({
|
|
25489
|
+
__proto__: null,
|
|
25490
|
+
EdDSAEnvelopeSigner: EdDSAEnvelopeSigner
|
|
25491
|
+
});
|
|
25492
|
+
|
|
25353
25493
|
const logger$x = getLogger('naylence.fame.security.auth.jwt_token_issuer');
|
|
25354
25494
|
let joseModulePromise = null;
|
|
25355
25495
|
async function requireJose() {
|
|
@@ -39457,146 +39597,6 @@ var sharedSecretTokenVerifier = /*#__PURE__*/Object.freeze({
|
|
|
39457
39597
|
SharedSecretTokenVerifier: SharedSecretTokenVerifier
|
|
39458
39598
|
});
|
|
39459
39599
|
|
|
39460
|
-
if (!ed25519.hashes.sha512) {
|
|
39461
|
-
ed25519.hashes.sha512 = (message) => sha2_js.sha512(message);
|
|
39462
|
-
}
|
|
39463
|
-
function normalizeSignerOptions(options) {
|
|
39464
|
-
if (!options || typeof options !== 'object') {
|
|
39465
|
-
return {};
|
|
39466
|
-
}
|
|
39467
|
-
const candidate = options;
|
|
39468
|
-
const result = {
|
|
39469
|
-
...options,
|
|
39470
|
-
};
|
|
39471
|
-
const cryptoProvider = resolveAlias(candidate, ['cryptoProvider', 'crypto_provider']);
|
|
39472
|
-
if (cryptoProvider !== undefined) {
|
|
39473
|
-
result.cryptoProvider = cryptoProvider ?? null;
|
|
39474
|
-
}
|
|
39475
|
-
const signingConfig = resolveAlias(candidate, ['signingConfig', 'signing_config']);
|
|
39476
|
-
if (signingConfig !== undefined) {
|
|
39477
|
-
result.signingConfig = signingConfig;
|
|
39478
|
-
}
|
|
39479
|
-
const privateKeyPem = resolveAlias(candidate, [
|
|
39480
|
-
'privateKeyPem',
|
|
39481
|
-
'private_key_pem',
|
|
39482
|
-
]);
|
|
39483
|
-
if (privateKeyPem !== undefined) {
|
|
39484
|
-
result.privateKeyPem = privateKeyPem;
|
|
39485
|
-
}
|
|
39486
|
-
const keyId = resolveAlias(candidate, [
|
|
39487
|
-
'keyId',
|
|
39488
|
-
'key_id',
|
|
39489
|
-
]);
|
|
39490
|
-
if (keyId !== undefined) {
|
|
39491
|
-
result.keyId = keyId;
|
|
39492
|
-
}
|
|
39493
|
-
return result;
|
|
39494
|
-
}
|
|
39495
|
-
class EdDSAEnvelopeSigner {
|
|
39496
|
-
constructor(options = {}) {
|
|
39497
|
-
const normalized = normalizeSignerOptions(options);
|
|
39498
|
-
const provider = normalized.cryptoProvider ?? null;
|
|
39499
|
-
if (!provider) {
|
|
39500
|
-
throw new Error('No crypto provider is configured for signing');
|
|
39501
|
-
}
|
|
39502
|
-
this.crypto = provider;
|
|
39503
|
-
const signingConfigOption = normalized.signingConfig;
|
|
39504
|
-
if (signingConfigOption instanceof SigningConfig) {
|
|
39505
|
-
this.signingConfig = signingConfigOption;
|
|
39506
|
-
}
|
|
39507
|
-
else if (signingConfigOption) {
|
|
39508
|
-
this.signingConfig = new SigningConfig(signingConfigOption);
|
|
39509
|
-
}
|
|
39510
|
-
else {
|
|
39511
|
-
this.signingConfig = new SigningConfig();
|
|
39512
|
-
}
|
|
39513
|
-
this.explicitPrivateKey = normalized.privateKeyPem;
|
|
39514
|
-
this.explicitKeyId = normalized.keyId;
|
|
39515
|
-
}
|
|
39516
|
-
signEnvelope(envelope, { physicalPath }) {
|
|
39517
|
-
if (!envelope.sid) {
|
|
39518
|
-
throw new Error('Envelope missing sid');
|
|
39519
|
-
}
|
|
39520
|
-
const frame = envelope.frame;
|
|
39521
|
-
if (frame.type === 'Data') {
|
|
39522
|
-
const dataFrame = frame;
|
|
39523
|
-
if (!dataFrame.pd) {
|
|
39524
|
-
const payload = dataFrame.payload ?? '';
|
|
39525
|
-
const payloadString = payload === '' ? '' : canonicalJson(payload);
|
|
39526
|
-
dataFrame.pd = secureDigest(payloadString);
|
|
39527
|
-
}
|
|
39528
|
-
}
|
|
39529
|
-
const digest = frameDigest(frame);
|
|
39530
|
-
const immutable = canonicalJson(immutableHeaders(envelope));
|
|
39531
|
-
const sidDigest = secureDigest(physicalPath);
|
|
39532
|
-
const tbs = new Uint8Array(encodeUtf8(sidDigest).length +
|
|
39533
|
-
1 +
|
|
39534
|
-
encodeUtf8(immutable).length +
|
|
39535
|
-
1 +
|
|
39536
|
-
encodeUtf8(digest).length);
|
|
39537
|
-
const sidBytes = encodeUtf8(sidDigest);
|
|
39538
|
-
const immBytes = encodeUtf8(immutable);
|
|
39539
|
-
const digBytes = encodeUtf8(digest);
|
|
39540
|
-
let offset = 0;
|
|
39541
|
-
tbs.set(sidBytes, offset);
|
|
39542
|
-
offset += sidBytes.length;
|
|
39543
|
-
tbs[offset] = 0x1f;
|
|
39544
|
-
offset += 1;
|
|
39545
|
-
tbs.set(immBytes, offset);
|
|
39546
|
-
offset += immBytes.length;
|
|
39547
|
-
tbs[offset] = 0x1f;
|
|
39548
|
-
offset += 1;
|
|
39549
|
-
tbs.set(digBytes, offset);
|
|
39550
|
-
const privateKey = this.loadPrivateKey();
|
|
39551
|
-
const signatureBytes = ed25519.sign(tbs, privateKey);
|
|
39552
|
-
const signature = urlsafeBase64Encode(signatureBytes);
|
|
39553
|
-
const kid = this.determineKeyId();
|
|
39554
|
-
const signatureHeader = {
|
|
39555
|
-
kid,
|
|
39556
|
-
val: signature,
|
|
39557
|
-
alg: 'EdDSA',
|
|
39558
|
-
};
|
|
39559
|
-
const secHeader = envelope.sec ?? {};
|
|
39560
|
-
secHeader.sig = signatureHeader;
|
|
39561
|
-
envelope.sec = secHeader;
|
|
39562
|
-
return envelope;
|
|
39563
|
-
}
|
|
39564
|
-
loadPrivateKey() {
|
|
39565
|
-
const pem = this.explicitPrivateKey ??
|
|
39566
|
-
readStringProperty(this.crypto, 'signingPrivatePem', 'signing_private_pem');
|
|
39567
|
-
if (!pem) {
|
|
39568
|
-
throw new Error('Crypto provider does not expose a signing private key');
|
|
39569
|
-
}
|
|
39570
|
-
return parseEd25519PrivateKey(pem);
|
|
39571
|
-
}
|
|
39572
|
-
determineKeyId() {
|
|
39573
|
-
if (this.explicitKeyId) {
|
|
39574
|
-
return this.explicitKeyId;
|
|
39575
|
-
}
|
|
39576
|
-
if (this.signingConfig.signingMaterial === core.SigningMaterial.X509_CHAIN) {
|
|
39577
|
-
const certificateProvider = this
|
|
39578
|
-
.crypto;
|
|
39579
|
-
const jwk = certificateProvider.nodeJwk?.();
|
|
39580
|
-
if (jwk && typeof jwk === 'object' && 'kid' in jwk && 'x5c' in jwk) {
|
|
39581
|
-
const kid = jwk.kid;
|
|
39582
|
-
if (typeof kid === 'string' && kid.length > 0) {
|
|
39583
|
-
return kid;
|
|
39584
|
-
}
|
|
39585
|
-
}
|
|
39586
|
-
}
|
|
39587
|
-
const fallback = readStringProperty(this.crypto, 'signatureKeyId', 'signature_key_id');
|
|
39588
|
-
if (!fallback) {
|
|
39589
|
-
throw new Error('Crypto provider does not expose a signature key id');
|
|
39590
|
-
}
|
|
39591
|
-
return fallback;
|
|
39592
|
-
}
|
|
39593
|
-
}
|
|
39594
|
-
|
|
39595
|
-
var eddsaEnvelopeSigner = /*#__PURE__*/Object.freeze({
|
|
39596
|
-
__proto__: null,
|
|
39597
|
-
EdDSAEnvelopeSigner: EdDSAEnvelopeSigner
|
|
39598
|
-
});
|
|
39599
|
-
|
|
39600
39600
|
async function loadPublicKey(jwk, signingConfig) {
|
|
39601
39601
|
if (jwk.x5c) {
|
|
39602
39602
|
if (signingConfig.signingMaterial !== core.SigningMaterial.X509_CHAIN) {
|
|
@@ -39884,6 +39884,7 @@ exports.ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE = ENV_VAR_JWT_REVERSE_AUTH_AUDIENCE;
|
|
|
39884
39884
|
exports.ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER = ENV_VAR_JWT_REVERSE_AUTH_TRUSTED_ISSUER;
|
|
39885
39885
|
exports.ENV_VAR_JWT_TRUSTED_ISSUER = ENV_VAR_JWT_TRUSTED_ISSUER;
|
|
39886
39886
|
exports.ENV_VAR_SHOW_ENVELOPES = ENV_VAR_SHOW_ENVELOPES$1;
|
|
39887
|
+
exports.EdDSAEnvelopeSigner = EdDSAEnvelopeSigner;
|
|
39887
39888
|
exports.EncryptedKeyValueStore = EncryptedKeyValueStore;
|
|
39888
39889
|
exports.EncryptedStorageProviderBase = EncryptedStorageProviderBase;
|
|
39889
39890
|
exports.EncryptedValue = EncryptedValue;
|