@smartledger/bsv 7.5.1 → 7.5.3
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 +110 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +33 -33
- package/bsv-ltp.min.js +33 -33
- package/bsv-smartcontract.min.js +2 -2
- package/bsv-statuslist.min.js +1 -1
- package/bsv.bundle.js +33 -33
- package/bsv.d.ts +56 -11
- package/bsv.min.js +33 -33
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/index.js +4 -1
- package/lib/gdaf/smartledger-anchor.js +120 -11
- package/lib/smart_contract/authorizers.js +8 -0
- package/lib/smart_contract/index.js +4 -2
- package/lib/statuslist/index.js +11 -3
- package/package.json +12 -1
- package/test/gdaf/anchor_no_key_leak.js +59 -1
- package/test/types/dts_drift.js +23 -1
- package/test/types/surface_honesty.js +102 -0
- package/version.js +1 -1
package/bsv.d.ts
CHANGED
|
@@ -230,6 +230,11 @@ declare module '@smartledger/bsv' {
|
|
|
230
230
|
static isValid(data: string): boolean;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Callable with or without `new` — `bsv.Message(msg)` is the form the docs and
|
|
235
|
+
* examples use, and was previously untyped.
|
|
236
|
+
*/
|
|
237
|
+
export function Message(message: string | Buffer): Message;
|
|
233
238
|
export class Message {
|
|
234
239
|
constructor(message: string | Buffer);
|
|
235
240
|
|
|
@@ -344,7 +349,13 @@ declare module '@smartledger/bsv' {
|
|
|
344
349
|
function buildP2SHMultisigIn(pubkeys: PublicKey[], threshold: number, signatures: Buffer[], opts: object): Script;
|
|
345
350
|
function buildPublicKeyHashOut(address: Address): Script;
|
|
346
351
|
function buildPublicKeyOut(pubkey: PublicKey): Script;
|
|
352
|
+
/**
|
|
353
|
+
* Bare `OP_RETURN <data>`. Prefer buildSafeDataOut: a bare OP_RETURN is not
|
|
354
|
+
* provably unspendable.
|
|
355
|
+
*/
|
|
347
356
|
function buildDataOut(data: string | Buffer, encoding?: string): Script;
|
|
357
|
+
/** `OP_FALSE OP_RETURN <data>` — provably unspendable. Partner of isSafeDataOut(). */
|
|
358
|
+
function buildSafeDataOut(data: string | Buffer, encoding?: string): Script;
|
|
348
359
|
function buildScriptHashOut(script: Script): Script;
|
|
349
360
|
function buildPublicKeyIn(signature: crypto.Signature | Buffer, sigtype: number): Script;
|
|
350
361
|
function buildPublicKeyHashIn(publicKey: PublicKey, signature: crypto.Signature | Buffer, sigtype: number): Script;
|
|
@@ -468,7 +479,7 @@ declare module '@smartledger/bsv' {
|
|
|
468
479
|
|
|
469
480
|
function add(data: any): Network;
|
|
470
481
|
function remove(network: Network): void;
|
|
471
|
-
function get(args: string | number | Network, keys
|
|
482
|
+
function get(args: string | number | Network, keys?: string | string[]): Network;
|
|
472
483
|
}
|
|
473
484
|
|
|
474
485
|
export class Address {
|
|
@@ -624,27 +635,55 @@ declare module '@smartledger/bsv' {
|
|
|
624
635
|
|
|
625
636
|
// -------- StatusList2021 --------------------------------------------
|
|
626
637
|
|
|
627
|
-
|
|
638
|
+
/**
|
|
639
|
+
* 'suspended' is part of the StatusList2021 vocabulary but is NOT writable here:
|
|
640
|
+
* this implementation hardcodes statusPurpose 'revocation' and uses one bit, so
|
|
641
|
+
* updateStatusList throws on it rather than recording a suspension as a revocation.
|
|
642
|
+
*/
|
|
643
|
+
export type CredentialStatus = 'valid' | 'revoked' | 'suspended';
|
|
628
644
|
|
|
629
645
|
export namespace StatusList {
|
|
646
|
+
/**
|
|
647
|
+
* Reading revocation state verifies the list JWT's signature and pins its issuer;
|
|
648
|
+
* both are required and were previously absent from these declarations.
|
|
649
|
+
*/
|
|
650
|
+
interface StatusListReadParams {
|
|
651
|
+
listVcJwt: string;
|
|
652
|
+
index: number;
|
|
653
|
+
/** Required: the issuer this list must be signed by. */
|
|
654
|
+
expectedIssuerDid: string;
|
|
655
|
+
/** Supply exactly one key source. */
|
|
656
|
+
didResolver?: (did: string) => Promise<{ jwks: { keys: Jwk[] } }>;
|
|
657
|
+
issuerJwks?: { keys: Jwk[] };
|
|
658
|
+
issuerPublicJwk?: Jwk;
|
|
659
|
+
allowedAlgs?: string[];
|
|
660
|
+
}
|
|
630
661
|
function createStatusList(params: {
|
|
631
662
|
issuerDid: string;
|
|
632
663
|
privateJwk: Jwk;
|
|
633
664
|
listId?: string;
|
|
634
665
|
listSize?: number;
|
|
635
666
|
}): Promise<{ listVcJwt: string; listId: string }>;
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
667
|
+
/**
|
|
668
|
+
* Verifying the existing list before building on it requires pinning its issuer,
|
|
669
|
+
* so `expectedIssuerDid` plus one key source are mandatory at runtime.
|
|
670
|
+
*/
|
|
671
|
+
function updateStatusList(params: StatusListReadParams & {
|
|
639
672
|
status: CredentialStatus;
|
|
640
673
|
privateJwk: Jwk;
|
|
641
674
|
}): Promise<{ listVcJwt: string }>;
|
|
642
|
-
|
|
675
|
+
/**
|
|
676
|
+
* ASYNC — returns a Promise. Declared synchronous until 7.5.2, which meant
|
|
677
|
+
* `if (getCredentialStatusEntry(...) === 'revoked')` type-checked and was ALWAYS
|
|
678
|
+
* false, so every revoked credential passed. Await it.
|
|
679
|
+
*/
|
|
680
|
+
function getCredentialStatusEntry(params: StatusListReadParams): Promise<CredentialStatus>;
|
|
643
681
|
}
|
|
644
682
|
|
|
645
683
|
// -------- Anchor (top-level hash anchoring) -------------------------
|
|
646
684
|
|
|
647
|
-
|
|
685
|
+
/** Closed set: the runtime rejects anything else with "Invalid kind. Must be one of: ...". */
|
|
686
|
+
export type AnchorKind = 'VC_ANCHOR_SHA256' | 'STATUSLIST_SHA256' | 'PRESENTATION_SHA256';
|
|
648
687
|
|
|
649
688
|
export interface AnchorPayload {
|
|
650
689
|
json: object;
|
|
@@ -942,7 +981,8 @@ declare module '@smartledger/bsv' {
|
|
|
942
981
|
/** Perpetually Enforcing Locking Script: every spend recreates the same script (value - fee). */
|
|
943
982
|
function perpetualCovenant(fee: number): Script;
|
|
944
983
|
/** Stateful ownership token (NFT) locking script. */
|
|
945
|
-
|
|
984
|
+
/** Alias of SmartContract.Token.ownershipToken, authorizer included. */
|
|
985
|
+
function ownershipToken(fee: number, ownerHash: Buffer, auth?: SmartContract.Authorizer): Script;
|
|
946
986
|
/** OP_PUSH_TX value/output covenant: coins can only go where the covenant says. */
|
|
947
987
|
function valueCovenant(expectedHashOutputs: Buffer): Script;
|
|
948
988
|
/** Ordinal covenant locking script (value-preserving; safe for 1-sat ordinals). */
|
|
@@ -1009,8 +1049,12 @@ declare module '@smartledger/bsv' {
|
|
|
1009
1049
|
namespace Authorizers {
|
|
1010
1050
|
/** Single-key (default): owner id = HASH160(pubkey). */
|
|
1011
1051
|
function singleKey(): Authorizer;
|
|
1012
|
-
/**
|
|
1013
|
-
|
|
1052
|
+
/**
|
|
1053
|
+
* m-of-n multisig authorizer. `nKeys` is the NUMBER of keys, not the keys —
|
|
1054
|
+
* the descriptor supplies them at spend time. (Locks.multisig genuinely does
|
|
1055
|
+
* take keys, which is what made this easy to walk into.)
|
|
1056
|
+
*/
|
|
1057
|
+
function multisig(m: number, nKeys: number): Authorizer;
|
|
1014
1058
|
/** Arbitrary predicate authorizer over a fixed 20-byte commitment. */
|
|
1015
1059
|
function predicate(commit: Buffer, emit: (script: Script) => Script): Authorizer;
|
|
1016
1060
|
}
|
|
@@ -1360,7 +1404,8 @@ declare module '@smartledger/bsv' {
|
|
|
1360
1404
|
export function getClaimSchemaNames(): string[];
|
|
1361
1405
|
export function getClaimSchema(schemaName: string): object;
|
|
1362
1406
|
export function createClaimTemplate(schemaName: string): object;
|
|
1363
|
-
|
|
1407
|
+
/** Returns the canonical JSON STRING, not an object. */
|
|
1408
|
+
export function canonicalizeClaim(claim: object): string;
|
|
1364
1409
|
export function hashClaim(claim: object): string;
|
|
1365
1410
|
export function addCustomClaimSchema(name: string, schema: object): void;
|
|
1366
1411
|
|