@smartledger/keys 1.0.1 → 1.1.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/dist/lumen-keys.js +171 -0
- package/dist/lumen-keys.js.map +4 -4
- package/dist/lumen-keys.min.js +1 -1
- package/dist/lumen-keys.min.js.map +4 -4
- package/package.json +4 -4
package/dist/lumen-keys.js
CHANGED
|
@@ -1502,6 +1502,175 @@ var LumenKeys = (() => {
|
|
|
1502
1502
|
}
|
|
1503
1503
|
});
|
|
1504
1504
|
|
|
1505
|
+
// ../crypto/dist/errors.js
|
|
1506
|
+
var require_errors = __commonJS({
|
|
1507
|
+
"../crypto/dist/errors.js"(exports2) {
|
|
1508
|
+
"use strict";
|
|
1509
|
+
init_esbuild_shims();
|
|
1510
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1511
|
+
exports2.ComplianceViolationError = exports2.InvalidKeyParametersError = exports2.CryptoOperationError = exports2.InvalidSignatureError = exports2.SuiteNotFoundError = exports2.SuiteNotAllowedError = exports2.KeyInvalidStateError = exports2.KeyExpiredError = exports2.KeyNotFoundError = exports2.SmartLedgerCryptoError = void 0;
|
|
1512
|
+
var SmartLedgerCryptoError = class extends Error {
|
|
1513
|
+
constructor(message, code) {
|
|
1514
|
+
super(message);
|
|
1515
|
+
__publicField(this, "code");
|
|
1516
|
+
this.code = code;
|
|
1517
|
+
this.name = this.constructor.name;
|
|
1518
|
+
Error.captureStackTrace(this, this.constructor);
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
exports2.SmartLedgerCryptoError = SmartLedgerCryptoError;
|
|
1522
|
+
var KeyNotFoundError = class extends SmartLedgerCryptoError {
|
|
1523
|
+
constructor(keyId) {
|
|
1524
|
+
super(`Key not found: ${keyId}`, "KEY_NOT_FOUND");
|
|
1525
|
+
__publicField(this, "keyId");
|
|
1526
|
+
this.keyId = keyId;
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1529
|
+
exports2.KeyNotFoundError = KeyNotFoundError;
|
|
1530
|
+
var KeyExpiredError = class extends SmartLedgerCryptoError {
|
|
1531
|
+
constructor(keyId, expiresAt) {
|
|
1532
|
+
super(`Key expired: ${keyId} (expired at ${expiresAt})`, "KEY_EXPIRED");
|
|
1533
|
+
__publicField(this, "keyId");
|
|
1534
|
+
__publicField(this, "expiresAt");
|
|
1535
|
+
this.keyId = keyId;
|
|
1536
|
+
this.expiresAt = expiresAt;
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
exports2.KeyExpiredError = KeyExpiredError;
|
|
1540
|
+
var KeyInvalidStateError = class extends SmartLedgerCryptoError {
|
|
1541
|
+
constructor(keyId, currentState, requiredState) {
|
|
1542
|
+
super(`Key in invalid state: ${keyId} (current: ${currentState}, required: ${requiredState})`, "KEY_INVALID_STATE");
|
|
1543
|
+
__publicField(this, "keyId");
|
|
1544
|
+
__publicField(this, "currentState");
|
|
1545
|
+
__publicField(this, "requiredState");
|
|
1546
|
+
this.keyId = keyId;
|
|
1547
|
+
this.currentState = currentState;
|
|
1548
|
+
this.requiredState = requiredState;
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
exports2.KeyInvalidStateError = KeyInvalidStateError;
|
|
1552
|
+
var SuiteNotAllowedError = class extends SmartLedgerCryptoError {
|
|
1553
|
+
constructor(suiteId, profileName) {
|
|
1554
|
+
const profileMsg = profileName ? ` in profile ${profileName}` : "";
|
|
1555
|
+
super(`Suite not allowed: ${suiteId}${profileMsg}`, "SUITE_NOT_ALLOWED");
|
|
1556
|
+
__publicField(this, "suiteId");
|
|
1557
|
+
__publicField(this, "profileName");
|
|
1558
|
+
this.suiteId = suiteId;
|
|
1559
|
+
this.profileName = profileName;
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
exports2.SuiteNotAllowedError = SuiteNotAllowedError;
|
|
1563
|
+
var SuiteNotFoundError = class extends SmartLedgerCryptoError {
|
|
1564
|
+
constructor(suiteId) {
|
|
1565
|
+
super(`Suite not found: ${suiteId}`, "SUITE_NOT_FOUND");
|
|
1566
|
+
__publicField(this, "suiteId");
|
|
1567
|
+
this.suiteId = suiteId;
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
exports2.SuiteNotFoundError = SuiteNotFoundError;
|
|
1571
|
+
var InvalidSignatureError = class extends SmartLedgerCryptoError {
|
|
1572
|
+
constructor(keyId, message = "Signature verification failed") {
|
|
1573
|
+
super(message, "INVALID_SIGNATURE");
|
|
1574
|
+
__publicField(this, "keyId");
|
|
1575
|
+
this.keyId = keyId;
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
exports2.InvalidSignatureError = InvalidSignatureError;
|
|
1579
|
+
var CryptoOperationError = class extends SmartLedgerCryptoError {
|
|
1580
|
+
constructor(operation, message, cause) {
|
|
1581
|
+
super(`Cryptographic operation failed (${operation}): ${message}`, "CRYPTO_OPERATION_FAILED");
|
|
1582
|
+
__publicField(this, "operation");
|
|
1583
|
+
__publicField(this, "cause");
|
|
1584
|
+
this.operation = operation;
|
|
1585
|
+
this.cause = cause;
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
exports2.CryptoOperationError = CryptoOperationError;
|
|
1589
|
+
var InvalidKeyParametersError = class extends SmartLedgerCryptoError {
|
|
1590
|
+
constructor(message) {
|
|
1591
|
+
super(`Invalid key parameters: ${message}`, "INVALID_KEY_PARAMETERS");
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
exports2.InvalidKeyParametersError = InvalidKeyParametersError;
|
|
1595
|
+
var ComplianceViolationError = class extends SmartLedgerCryptoError {
|
|
1596
|
+
constructor(profileName, violation) {
|
|
1597
|
+
super(`Compliance violation in profile ${profileName}: ${violation}`, "COMPLIANCE_VIOLATION");
|
|
1598
|
+
__publicField(this, "profileName");
|
|
1599
|
+
__publicField(this, "violation");
|
|
1600
|
+
this.profileName = profileName;
|
|
1601
|
+
this.violation = violation;
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
exports2.ComplianceViolationError = ComplianceViolationError;
|
|
1605
|
+
}
|
|
1606
|
+
});
|
|
1607
|
+
|
|
1608
|
+
// ../crypto/dist/stateless.js
|
|
1609
|
+
var require_stateless = __commonJS({
|
|
1610
|
+
"../crypto/dist/stateless.js"(exports2) {
|
|
1611
|
+
"use strict";
|
|
1612
|
+
init_esbuild_shims();
|
|
1613
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1614
|
+
exports2.setGlobalRegistry = setGlobalRegistry;
|
|
1615
|
+
exports2.signUsingSuite = signUsingSuite;
|
|
1616
|
+
exports2.verifyUsingSuite = verifyUsingSuite;
|
|
1617
|
+
exports2.generateKeypairUsingSuite = generateKeypairUsingSuite;
|
|
1618
|
+
exports2.listAvailableSuites = listAvailableSuites;
|
|
1619
|
+
var registry_js_1 = require_registry();
|
|
1620
|
+
var errors_js_1 = require_errors();
|
|
1621
|
+
var globalRegistry = null;
|
|
1622
|
+
function setGlobalRegistry(registry) {
|
|
1623
|
+
globalRegistry = registry;
|
|
1624
|
+
}
|
|
1625
|
+
function getRegistry() {
|
|
1626
|
+
if (!globalRegistry) {
|
|
1627
|
+
globalRegistry = new registry_js_1.SignatureSuiteRegistry();
|
|
1628
|
+
}
|
|
1629
|
+
return globalRegistry;
|
|
1630
|
+
}
|
|
1631
|
+
async function signUsingSuite(suiteId, privateKey, message) {
|
|
1632
|
+
const registry = getRegistry();
|
|
1633
|
+
if (!registry.hasSuite(suiteId)) {
|
|
1634
|
+
throw new errors_js_1.SuiteNotFoundError(suiteId);
|
|
1635
|
+
}
|
|
1636
|
+
try {
|
|
1637
|
+
const suite = registry.getSuite(suiteId);
|
|
1638
|
+
return await suite.sign(privateKey, message);
|
|
1639
|
+
} catch (error) {
|
|
1640
|
+
throw new errors_js_1.CryptoOperationError("sign", error instanceof Error ? error.message : "Unknown error", error instanceof Error ? error : void 0);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
async function verifyUsingSuite(suiteId, publicKey, message, signature) {
|
|
1644
|
+
const registry = getRegistry();
|
|
1645
|
+
if (!registry.hasSuite(suiteId)) {
|
|
1646
|
+
throw new errors_js_1.SuiteNotFoundError(suiteId);
|
|
1647
|
+
}
|
|
1648
|
+
try {
|
|
1649
|
+
const suite = registry.getSuite(suiteId);
|
|
1650
|
+
return await suite.verify(publicKey, message, signature);
|
|
1651
|
+
} catch (error) {
|
|
1652
|
+
throw new errors_js_1.CryptoOperationError("verify", error instanceof Error ? error.message : "Unknown error", error instanceof Error ? error : void 0);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
async function generateKeypairUsingSuite(suiteId) {
|
|
1656
|
+
const registry = getRegistry();
|
|
1657
|
+
if (!registry.hasSuite(suiteId)) {
|
|
1658
|
+
throw new errors_js_1.SuiteNotFoundError(suiteId);
|
|
1659
|
+
}
|
|
1660
|
+
try {
|
|
1661
|
+
const suite = registry.getSuite(suiteId);
|
|
1662
|
+
return await suite.generateKeypair();
|
|
1663
|
+
} catch (error) {
|
|
1664
|
+
throw new errors_js_1.CryptoOperationError("generateKeypair", error instanceof Error ? error.message : "Unknown error", error instanceof Error ? error : void 0);
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
function listAvailableSuites() {
|
|
1668
|
+
const registry = getRegistry();
|
|
1669
|
+
return registry.listSuites();
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
|
|
1505
1674
|
// ../../node_modules/@noble/secp256k1/index.js
|
|
1506
1675
|
var secp256k1_exports = {};
|
|
1507
1676
|
__export(secp256k1_exports, {
|
|
@@ -4964,6 +5133,8 @@ var LumenKeys = (() => {
|
|
|
4964
5133
|
__exportStar(require_utils(), exports2);
|
|
4965
5134
|
__exportStar(require_signing(), exports2);
|
|
4966
5135
|
__exportStar(require_key_registry(), exports2);
|
|
5136
|
+
__exportStar(require_errors(), exports2);
|
|
5137
|
+
__exportStar(require_stateless(), exports2);
|
|
4967
5138
|
var bsv_ecdsa_1 = require_bsv_ecdsa();
|
|
4968
5139
|
Object.defineProperty(exports2, "BsvEcdsaSuite", { enumerable: true, get: function() {
|
|
4969
5140
|
return bsv_ecdsa_1.BsvEcdsaSuite;
|