@did-btcr2/method 0.16.0 → 0.17.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/browser.js +182 -202
- package/dist/browser.mjs +182 -202
- package/dist/cjs/core/beacon/aggregation/protocol/nostr.js +1 -1
- package/dist/cjs/core/beacon/aggregation/protocol/nostr.js.map +1 -1
- package/dist/cjs/core/crud/update.js +1 -1
- package/dist/cjs/core/crud/update.js.map +1 -1
- package/dist/cjs/did-btcr2.js +7 -19
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/did-document.js +61 -13
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/protocol/nostr.js +1 -1
- package/dist/esm/core/beacon/aggregation/protocol/nostr.js.map +1 -1
- package/dist/esm/core/crud/update.js +1 -1
- package/dist/esm/core/crud/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +7 -19
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/did-document.js +61 -13
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/types/core/crud/update.d.ts +10 -0
- package/dist/types/core/crud/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +16 -5
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +25 -10
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/core/beacon/aggregation/protocol/nostr.ts +1 -1
- package/src/core/crud/update.ts +13 -1
- package/src/did-btcr2.ts +25 -25
- package/src/index.ts +0 -1
- package/src/utils/did-document.ts +72 -16
- package/dist/cjs/core/crud/create.js +0 -102
- package/dist/cjs/core/crud/create.js.map +0 -1
- package/dist/esm/core/crud/create.js +0 -102
- package/dist/esm/core/crud/create.js.map +0 -1
- package/dist/types/core/crud/create.d.ts +0 -92
- package/dist/types/core/crud/create.d.ts.map +0 -1
- package/src/core/crud/create.ts +0 -160
package/dist/browser.js
CHANGED
|
@@ -45004,11 +45004,11 @@ var BTCR2 = (() => {
|
|
|
45004
45004
|
};
|
|
45005
45005
|
metadataRegistry.registerProvider(provider);
|
|
45006
45006
|
return provider;
|
|
45007
|
-
function GetOrCreateMetadataMap(O, P3,
|
|
45007
|
+
function GetOrCreateMetadataMap(O, P3, Create) {
|
|
45008
45008
|
var targetMetadata = metadata2.get(O);
|
|
45009
45009
|
var createdTargetMetadata = false;
|
|
45010
45010
|
if (IsUndefined(targetMetadata)) {
|
|
45011
|
-
if (!
|
|
45011
|
+
if (!Create)
|
|
45012
45012
|
return void 0;
|
|
45013
45013
|
targetMetadata = new _Map();
|
|
45014
45014
|
metadata2.set(O, targetMetadata);
|
|
@@ -45016,7 +45016,7 @@ var BTCR2 = (() => {
|
|
|
45016
45016
|
}
|
|
45017
45017
|
var metadataMap = targetMetadata.get(P3);
|
|
45018
45018
|
if (IsUndefined(metadataMap)) {
|
|
45019
|
-
if (!
|
|
45019
|
+
if (!Create)
|
|
45020
45020
|
return void 0;
|
|
45021
45021
|
metadataMap = new _Map();
|
|
45022
45022
|
targetMetadata.set(P3, metadataMap);
|
|
@@ -45143,12 +45143,12 @@ var BTCR2 = (() => {
|
|
|
45143
45143
|
};
|
|
45144
45144
|
return provider;
|
|
45145
45145
|
}
|
|
45146
|
-
function GetMetadataProvider(O, P3,
|
|
45146
|
+
function GetMetadataProvider(O, P3, Create) {
|
|
45147
45147
|
var registeredProvider = metadataRegistry.getProvider(O, P3);
|
|
45148
45148
|
if (!IsUndefined(registeredProvider)) {
|
|
45149
45149
|
return registeredProvider;
|
|
45150
45150
|
}
|
|
45151
|
-
if (
|
|
45151
|
+
if (Create) {
|
|
45152
45152
|
if (metadataRegistry.setProvider(O, P3, metadataProvider)) {
|
|
45153
45153
|
return metadataProvider;
|
|
45154
45154
|
}
|
|
@@ -45991,13 +45991,13 @@ var BTCR2 = (() => {
|
|
|
45991
45991
|
BeaconFactory: () => BeaconFactory,
|
|
45992
45992
|
BeaconUtils: () => BeaconUtils,
|
|
45993
45993
|
CIDAggregateBeacon: () => CIDAggregateBeacon,
|
|
45994
|
-
Create: () => Create,
|
|
45995
45994
|
DID_REGEX: () => DID_REGEX,
|
|
45996
45995
|
Deactivate: () => Deactivate,
|
|
45997
45996
|
DidBtcr2: () => DidBtcr2,
|
|
45998
45997
|
DidDocument: () => DidDocument2,
|
|
45999
45998
|
DidDocumentBuilder: () => DidDocumentBuilder,
|
|
46000
45999
|
DidVerificationMethod: () => DidVerificationMethod,
|
|
46000
|
+
Document: () => Document,
|
|
46001
46001
|
GeneralUtils: () => GeneralUtils,
|
|
46002
46002
|
Identifier: () => Identifier,
|
|
46003
46003
|
IntermediateDidDocument: () => IntermediateDidDocument,
|
|
@@ -48513,6 +48513,45 @@ var BTCR2 = (() => {
|
|
|
48513
48513
|
// ../bitcoin/dist/esm/client/rest/index.js
|
|
48514
48514
|
init_shim();
|
|
48515
48515
|
|
|
48516
|
+
// ../bitcoin/dist/esm/constants.js
|
|
48517
|
+
init_shim();
|
|
48518
|
+
var TXIN_WITNESS_COINBASE = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
48519
|
+
var GENESIS_TX_ID = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";
|
|
48520
|
+
var DEFAULT_BITCOIN_NETWORK_CONFIG = {
|
|
48521
|
+
bitcoin: {
|
|
48522
|
+
rpc: void 0,
|
|
48523
|
+
rest: { host: "https://mempool.holdings/api" }
|
|
48524
|
+
},
|
|
48525
|
+
testnet3: {
|
|
48526
|
+
rpc: void 0,
|
|
48527
|
+
rest: { host: "https://mempool.holdings/testnet/api" }
|
|
48528
|
+
},
|
|
48529
|
+
testnet4: {
|
|
48530
|
+
rpc: void 0,
|
|
48531
|
+
rest: { host: "https://mempool.holdings/testnet4/api" }
|
|
48532
|
+
},
|
|
48533
|
+
signet: {
|
|
48534
|
+
rpc: void 0,
|
|
48535
|
+
rest: { host: "https://mempool.holdings/signet/api" }
|
|
48536
|
+
},
|
|
48537
|
+
mutinynet: {
|
|
48538
|
+
rpc: void 0,
|
|
48539
|
+
rest: { host: "https://mutinynet.com/api" }
|
|
48540
|
+
},
|
|
48541
|
+
regtest: {
|
|
48542
|
+
rpc: {
|
|
48543
|
+
network: "regtest",
|
|
48544
|
+
host: "http://localhost:18443",
|
|
48545
|
+
port: 18443,
|
|
48546
|
+
username: "polaruser",
|
|
48547
|
+
password: "polarpass",
|
|
48548
|
+
allowDefaultWallet: true,
|
|
48549
|
+
version: "28.1.0"
|
|
48550
|
+
},
|
|
48551
|
+
rest: { host: "http://localhost:3000" }
|
|
48552
|
+
}
|
|
48553
|
+
};
|
|
48554
|
+
|
|
48516
48555
|
// ../bitcoin/dist/esm/client/rest/address.js
|
|
48517
48556
|
init_shim();
|
|
48518
48557
|
var BitcoinAddress = class {
|
|
@@ -48708,46 +48747,8 @@ var BTCR2 = (() => {
|
|
|
48708
48747
|
}
|
|
48709
48748
|
};
|
|
48710
48749
|
|
|
48711
|
-
// ../bitcoin/dist/esm/
|
|
48750
|
+
// ../bitcoin/dist/esm/types.js
|
|
48712
48751
|
init_shim();
|
|
48713
|
-
var TXIN_WITNESS_COINBASE = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
48714
|
-
var GENESIS_TX_ID = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";
|
|
48715
|
-
var DEFAULT_BITCOIN_NETWORK_CONFIG = {
|
|
48716
|
-
mainnet: {
|
|
48717
|
-
rpc: void 0,
|
|
48718
|
-
rest: { host: "https://mempool.space/api" }
|
|
48719
|
-
},
|
|
48720
|
-
testnet3: {
|
|
48721
|
-
rpc: void 0,
|
|
48722
|
-
rest: { host: "https://mempool.space/testnet/api" }
|
|
48723
|
-
},
|
|
48724
|
-
testnet4: {
|
|
48725
|
-
rpc: void 0,
|
|
48726
|
-
rest: { host: "https://mempool.space/testnet4/api" }
|
|
48727
|
-
},
|
|
48728
|
-
signet: {
|
|
48729
|
-
rpc: void 0,
|
|
48730
|
-
rest: { host: "https://mempool.space/signet/api" }
|
|
48731
|
-
},
|
|
48732
|
-
mutinynet: {
|
|
48733
|
-
rpc: void 0,
|
|
48734
|
-
rest: { host: "https://mutinynet.com/api" }
|
|
48735
|
-
},
|
|
48736
|
-
regtest: {
|
|
48737
|
-
rpc: {
|
|
48738
|
-
network: "regtest",
|
|
48739
|
-
host: "http://localhost:18443",
|
|
48740
|
-
port: 18443,
|
|
48741
|
-
username: "polaruser",
|
|
48742
|
-
password: "polarpass",
|
|
48743
|
-
allowDefaultWallet: true,
|
|
48744
|
-
version: "28.1.0"
|
|
48745
|
-
},
|
|
48746
|
-
rest: { host: "http://localhost:3000" }
|
|
48747
|
-
}
|
|
48748
|
-
};
|
|
48749
|
-
|
|
48750
|
-
// ../bitcoin/dist/esm/client/rest/index.js
|
|
48751
48752
|
var RestClientConfig = class {
|
|
48752
48753
|
host;
|
|
48753
48754
|
headers;
|
|
@@ -48756,6 +48757,51 @@ var BTCR2 = (() => {
|
|
|
48756
48757
|
this.headers = headers;
|
|
48757
48758
|
}
|
|
48758
48759
|
};
|
|
48760
|
+
var BitcoinRpcClientConfig = class _BitcoinRpcClientConfig {
|
|
48761
|
+
network;
|
|
48762
|
+
headers;
|
|
48763
|
+
host;
|
|
48764
|
+
logger;
|
|
48765
|
+
password;
|
|
48766
|
+
timeout;
|
|
48767
|
+
username;
|
|
48768
|
+
version;
|
|
48769
|
+
wallet;
|
|
48770
|
+
allowDefaultWallet;
|
|
48771
|
+
constructor(options2 = {
|
|
48772
|
+
headers: {},
|
|
48773
|
+
host: "http://localhost",
|
|
48774
|
+
logger: console,
|
|
48775
|
+
password: "",
|
|
48776
|
+
timeout: 3e4,
|
|
48777
|
+
username: "",
|
|
48778
|
+
version: "0.21.1",
|
|
48779
|
+
wallet: "",
|
|
48780
|
+
allowDefaultWallet: false
|
|
48781
|
+
}) {
|
|
48782
|
+
this.headers = options2.headers;
|
|
48783
|
+
this.host = options2.host;
|
|
48784
|
+
this.logger = options2.logger;
|
|
48785
|
+
this.password = options2.password;
|
|
48786
|
+
this.timeout = options2.timeout;
|
|
48787
|
+
this.username = options2.username;
|
|
48788
|
+
this.version = options2.version;
|
|
48789
|
+
this.wallet = options2.wallet;
|
|
48790
|
+
this.allowDefaultWallet = options2.allowDefaultWallet;
|
|
48791
|
+
}
|
|
48792
|
+
static initialize(options2) {
|
|
48793
|
+
return new _BitcoinRpcClientConfig(options2);
|
|
48794
|
+
}
|
|
48795
|
+
};
|
|
48796
|
+
var VerbosityLevel;
|
|
48797
|
+
(function(VerbosityLevel2) {
|
|
48798
|
+
VerbosityLevel2[VerbosityLevel2["hex"] = 0] = "hex";
|
|
48799
|
+
VerbosityLevel2[VerbosityLevel2["json"] = 1] = "json";
|
|
48800
|
+
VerbosityLevel2[VerbosityLevel2["jsonext"] = 2] = "jsonext";
|
|
48801
|
+
VerbosityLevel2[VerbosityLevel2["jsonextprev"] = 3] = "jsonextprev";
|
|
48802
|
+
})(VerbosityLevel || (VerbosityLevel = {}));
|
|
48803
|
+
|
|
48804
|
+
// ../bitcoin/dist/esm/client/rest/index.js
|
|
48759
48805
|
var BitcoinRestClient = class _BitcoinRestClient {
|
|
48760
48806
|
/**
|
|
48761
48807
|
* The encapsulated {@link RestClientConfig} object.
|
|
@@ -48848,52 +48894,6 @@ var BTCR2 = (() => {
|
|
|
48848
48894
|
// ../bitcoin/dist/esm/client/rpc/index.js
|
|
48849
48895
|
init_shim();
|
|
48850
48896
|
|
|
48851
|
-
// ../bitcoin/dist/esm/types.js
|
|
48852
|
-
init_shim();
|
|
48853
|
-
var BitcoinRpcClientConfig = class _BitcoinRpcClientConfig {
|
|
48854
|
-
network;
|
|
48855
|
-
headers;
|
|
48856
|
-
host;
|
|
48857
|
-
logger;
|
|
48858
|
-
password;
|
|
48859
|
-
timeout;
|
|
48860
|
-
username;
|
|
48861
|
-
version;
|
|
48862
|
-
wallet;
|
|
48863
|
-
allowDefaultWallet;
|
|
48864
|
-
constructor(options2 = {
|
|
48865
|
-
headers: {},
|
|
48866
|
-
host: "localhost",
|
|
48867
|
-
logger: console,
|
|
48868
|
-
password: "",
|
|
48869
|
-
timeout: 3e4,
|
|
48870
|
-
username: "",
|
|
48871
|
-
version: "0.21.1",
|
|
48872
|
-
wallet: "",
|
|
48873
|
-
allowDefaultWallet: false
|
|
48874
|
-
}) {
|
|
48875
|
-
this.headers = options2.headers;
|
|
48876
|
-
this.host = options2.host;
|
|
48877
|
-
this.logger = options2.logger;
|
|
48878
|
-
this.password = options2.password;
|
|
48879
|
-
this.timeout = options2.timeout;
|
|
48880
|
-
this.username = options2.username;
|
|
48881
|
-
this.version = options2.version;
|
|
48882
|
-
this.wallet = options2.wallet;
|
|
48883
|
-
this.allowDefaultWallet = options2.allowDefaultWallet;
|
|
48884
|
-
}
|
|
48885
|
-
static initialize(options2) {
|
|
48886
|
-
return new _BitcoinRpcClientConfig(options2);
|
|
48887
|
-
}
|
|
48888
|
-
};
|
|
48889
|
-
var VerbosityLevel;
|
|
48890
|
-
(function(VerbosityLevel2) {
|
|
48891
|
-
VerbosityLevel2[VerbosityLevel2["hex"] = 0] = "hex";
|
|
48892
|
-
VerbosityLevel2[VerbosityLevel2["json"] = 1] = "json";
|
|
48893
|
-
VerbosityLevel2[VerbosityLevel2["jsonext"] = 2] = "jsonext";
|
|
48894
|
-
VerbosityLevel2[VerbosityLevel2["jsonextprev"] = 3] = "jsonextprev";
|
|
48895
|
-
})(VerbosityLevel || (VerbosityLevel = {}));
|
|
48896
|
-
|
|
48897
48897
|
// ../bitcoin/dist/esm/client/rpc/json-rpc.js
|
|
48898
48898
|
init_shim();
|
|
48899
48899
|
|
|
@@ -48932,8 +48932,8 @@ var BTCR2 = (() => {
|
|
|
48932
48932
|
u.password = "";
|
|
48933
48933
|
this.url = u.toString().replace(/\/+$/, "");
|
|
48934
48934
|
}
|
|
48935
|
-
} catch {
|
|
48936
|
-
console.error(
|
|
48935
|
+
} catch (error) {
|
|
48936
|
+
console.error(`Invalid URL in Bitcoin RPC config: ${this.url}`, error);
|
|
48937
48937
|
}
|
|
48938
48938
|
}
|
|
48939
48939
|
}
|
|
@@ -57844,7 +57844,7 @@ var BTCR2 = (() => {
|
|
|
57844
57844
|
}
|
|
57845
57845
|
/**
|
|
57846
57846
|
* Computes the public key from the secret key bytes.
|
|
57847
|
-
* @returns {
|
|
57847
|
+
* @returns {CompressedSecp256k1PublicKey} The computed public key
|
|
57848
57848
|
*/
|
|
57849
57849
|
computePublicKey() {
|
|
57850
57850
|
const publicKeyBytes = tinysecp.pointFromScalar(this.bytes, true);
|
|
@@ -57854,7 +57854,7 @@ var BTCR2 = (() => {
|
|
|
57854
57854
|
if (publicKeyBytes.length !== 33) {
|
|
57855
57855
|
throw new SecretKeyError("Invalid compute: public key not compressed format", "COMPUTE_PUBLIC_KEY_ERROR");
|
|
57856
57856
|
}
|
|
57857
|
-
return publicKeyBytes;
|
|
57857
|
+
return new CompressedSecp256k1PublicKey(publicKeyBytes);
|
|
57858
57858
|
}
|
|
57859
57859
|
/**
|
|
57860
57860
|
* Converts the secret key to a JSON object.
|
|
@@ -57876,15 +57876,14 @@ var BTCR2 = (() => {
|
|
|
57876
57876
|
}
|
|
57877
57877
|
/**
|
|
57878
57878
|
* Checks if the public key is a valid secp256k1 point.
|
|
57879
|
-
* @param {CompressedSecp256k1PublicKey} pk The public key to validate
|
|
57880
57879
|
* @returns {boolean} True if the public key is valid, false otherwise
|
|
57881
57880
|
*/
|
|
57882
|
-
hasValidPublicKey(
|
|
57881
|
+
hasValidPublicKey() {
|
|
57882
|
+
const pk = this.computePublicKey();
|
|
57883
57883
|
if (!tinysecp.isPoint(pk.compressed)) {
|
|
57884
57884
|
return false;
|
|
57885
57885
|
}
|
|
57886
|
-
|
|
57887
|
-
return computed.equals(pk);
|
|
57886
|
+
return true;
|
|
57888
57887
|
}
|
|
57889
57888
|
/**
|
|
57890
57889
|
* Decodes the multibase string to the 34-byte secret key (2 byte prefix + 32 byte key).
|
|
@@ -57971,7 +57970,7 @@ var BTCR2 = (() => {
|
|
|
57971
57970
|
/**
|
|
57972
57971
|
* Generates a public key from the given secret key bytes.
|
|
57973
57972
|
* @param {KeyBytes} bytes The secret key bytes
|
|
57974
|
-
* @returns {
|
|
57973
|
+
* @returns {CompressedSecp256k1PublicKey} The computed public key bytes
|
|
57975
57974
|
*/
|
|
57976
57975
|
static getPublicKey(bytes3) {
|
|
57977
57976
|
return new _Secp256k1SecretKey(bytes3).computePublicKey();
|
|
@@ -58028,10 +58027,15 @@ var BTCR2 = (() => {
|
|
|
58028
58027
|
}
|
|
58029
58028
|
/**
|
|
58030
58029
|
* Parity of the SEC compressed public key.
|
|
58031
|
-
* @returns {
|
|
58030
|
+
* @returns {0x02 | 0x03} The parity byte (0x02 if even, 0x03 if odd).
|
|
58031
|
+
* @throws {PublicKeyError} If the parity byte is not 0x02 or 0x03.
|
|
58032
58032
|
*/
|
|
58033
58033
|
get parity() {
|
|
58034
|
-
|
|
58034
|
+
const parity = this._bytes[0];
|
|
58035
|
+
if (![2, 3].includes(parity)) {
|
|
58036
|
+
throw new PublicKeyError("Invalid state: parity byte must be 2 or 3", "PARITY_ERROR", { parity });
|
|
58037
|
+
}
|
|
58038
|
+
return parity;
|
|
58035
58039
|
}
|
|
58036
58040
|
/**
|
|
58037
58041
|
* Whether the SEC compressed public key has even Y.
|
|
@@ -58178,7 +58182,7 @@ var BTCR2 = (() => {
|
|
|
58178
58182
|
throw new PublicKeyError("Invalid arg: must be 32 byte secret key", "FROM_SECRET_KEY_ERROR");
|
|
58179
58183
|
}
|
|
58180
58184
|
const secret = sk instanceof Secp256k1SecretKey ? sk : new Secp256k1SecretKey(sk);
|
|
58181
|
-
return
|
|
58185
|
+
return secret.computePublicKey();
|
|
58182
58186
|
}
|
|
58183
58187
|
/**
|
|
58184
58188
|
* Computes modular exponentiation: (base^exp) % mod.
|
|
@@ -58260,7 +58264,7 @@ var BTCR2 = (() => {
|
|
|
58260
58264
|
} else if (params.publicKey instanceof Uint8Array) {
|
|
58261
58265
|
this._publicKey = new CompressedSecp256k1PublicKey(params.publicKey);
|
|
58262
58266
|
} else {
|
|
58263
|
-
this._publicKey =
|
|
58267
|
+
this._publicKey = this._secretKey.computePublicKey();
|
|
58264
58268
|
}
|
|
58265
58269
|
this._publicKeyMultibase = this._publicKey.multibase.encoded;
|
|
58266
58270
|
this._secretKeyMultibase = this._secretKey ? this._secretKey.multibase : "";
|
|
@@ -58286,8 +58290,13 @@ var BTCR2 = (() => {
|
|
|
58286
58290
|
* @throws {KeyPairError} If the public key is not a valid pair with the secret key.
|
|
58287
58291
|
*/
|
|
58288
58292
|
set publicKey(publicKey2) {
|
|
58289
|
-
if (this.secretKey
|
|
58290
|
-
|
|
58293
|
+
if (this.secretKey) {
|
|
58294
|
+
if (!this.secretKey.hasValidPublicKey()) {
|
|
58295
|
+
throw new KeyPairError("Secret key is not valid", "SECRET_KEY_ERROR");
|
|
58296
|
+
}
|
|
58297
|
+
const cPk = this.secretKey.computePublicKey();
|
|
58298
|
+
if (!publicKey2.equals(cPk))
|
|
58299
|
+
throw new KeyPairError("Public key is not a valid pair with the secret key", "PUBLIC_KEY_ERROR");
|
|
58291
58300
|
}
|
|
58292
58301
|
this._publicKey = publicKey2;
|
|
58293
58302
|
this._publicKeyMultibase = publicKey2.multibase.encoded;
|
|
@@ -145773,7 +145782,7 @@ a=end-of-candidates
|
|
|
145773
145782
|
* @throws {MultikeyError} if neither a publicKey nor a privateKey is provided
|
|
145774
145783
|
* @returns {SchnorrMultikey} A new Multikey instance
|
|
145775
145784
|
*/
|
|
145776
|
-
static
|
|
145785
|
+
static create({ id, controller, keys }) {
|
|
145777
145786
|
return new _SchnorrMultikey({ id, controller, keys });
|
|
145778
145787
|
}
|
|
145779
145788
|
/**
|
|
@@ -146374,7 +146383,14 @@ a=end-of-candidates
|
|
|
146374
146383
|
}
|
|
146375
146384
|
};
|
|
146376
146385
|
|
|
146377
|
-
// src/core/crud/
|
|
146386
|
+
// src/core/crud/deactivate.ts
|
|
146387
|
+
init_shim();
|
|
146388
|
+
|
|
146389
|
+
// src/did-btcr2.ts
|
|
146390
|
+
init_shim();
|
|
146391
|
+
var tinysecp4 = __toESM(require_dist2(), 1);
|
|
146392
|
+
|
|
146393
|
+
// src/core/crud/read.ts
|
|
146378
146394
|
init_shim();
|
|
146379
146395
|
|
|
146380
146396
|
// src/utils/beacons.ts
|
|
@@ -147142,6 +147158,7 @@ a=end-of-candidates
|
|
|
147142
147158
|
capabilityDelegation;
|
|
147143
147159
|
service;
|
|
147144
147160
|
constructor(document2) {
|
|
147161
|
+
console.log("Constructing DidDocument with document:", document2);
|
|
147145
147162
|
const idType = document2.id.includes("k1") ? IdentifierTypes.KEY : IdentifierTypes.EXTERNAL;
|
|
147146
147163
|
const isIntermediate = document2.id === ID_PLACEHOLDER_VALUE;
|
|
147147
147164
|
const { id, controller, verificationMethod: vm, service } = document2;
|
|
@@ -147381,6 +147398,7 @@ a=end-of-candidates
|
|
|
147381
147398
|
if (!_DidDocument.isValidVerificationRelationships(this)) {
|
|
147382
147399
|
throw new DidDocumentError("Invalid IntermediateDidDocument assertionMethod", INVALID_DID_DOCUMENT, this);
|
|
147383
147400
|
}
|
|
147401
|
+
return true;
|
|
147384
147402
|
}
|
|
147385
147403
|
/**
|
|
147386
147404
|
* Convert the DidDocument to an IntermediateDidDocument.
|
|
@@ -147395,19 +147413,7 @@ a=end-of-candidates
|
|
|
147395
147413
|
};
|
|
147396
147414
|
var IntermediateDidDocument = class _IntermediateDidDocument extends DidDocument2 {
|
|
147397
147415
|
constructor(document2) {
|
|
147398
|
-
|
|
147399
|
-
super(intermediateDocument);
|
|
147400
|
-
}
|
|
147401
|
-
/**
|
|
147402
|
-
* Create a minimal IntermediateDidDocument with a placeholder ID.
|
|
147403
|
-
* @param {Array<DidVerificationMethod>} verificationMethod The public key in multibase format.
|
|
147404
|
-
* @param {VerificationRelationships} relationships The public key in multibase format.
|
|
147405
|
-
* @param {Array<BeaconService>} service The service to be included in the document.
|
|
147406
|
-
* @returns {IntermediateDidDocument} A new IntermediateDidDocument with the placeholder ID.
|
|
147407
|
-
*/
|
|
147408
|
-
static create(verificationMethod, relationships, service) {
|
|
147409
|
-
const id = ID_PLACEHOLDER_VALUE;
|
|
147410
|
-
return new _IntermediateDidDocument({ id, ...relationships, verificationMethod, service });
|
|
147416
|
+
super(document2);
|
|
147411
147417
|
}
|
|
147412
147418
|
/**
|
|
147413
147419
|
* Convert the IntermediateDidDocument to a DidDocument by replacing the placeholder value with the provided DID.
|
|
@@ -147420,92 +147426,72 @@ a=end-of-candidates
|
|
|
147420
147426
|
return new DidDocument2(parseThis);
|
|
147421
147427
|
}
|
|
147422
147428
|
/**
|
|
147423
|
-
* Create a DidDocument
|
|
147424
|
-
* @param {
|
|
147425
|
-
* @returns {
|
|
147429
|
+
* Create an IntermediateDidDocument from a DidDocument by replacing the DID with a placeholder value.
|
|
147430
|
+
* @param {DidDocument} didDocument The DidDocument to convert.
|
|
147431
|
+
* @returns {IntermediateDidDocument} The IntermediateDidDocument representation of the DidDocument.
|
|
147426
147432
|
*/
|
|
147427
|
-
static
|
|
147428
|
-
|
|
147433
|
+
static fromDidDocument(didDocument) {
|
|
147434
|
+
const intermediateDocument = JSON.cloneReplace(didDocument, DID_REGEX, ID_PLACEHOLDER_VALUE);
|
|
147435
|
+
return new _IntermediateDidDocument(intermediateDocument);
|
|
147429
147436
|
}
|
|
147430
|
-
};
|
|
147431
|
-
|
|
147432
|
-
// src/core/crud/create.ts
|
|
147433
|
-
var Create = class {
|
|
147434
147437
|
/**
|
|
147435
|
-
*
|
|
147436
|
-
*
|
|
147437
|
-
*
|
|
147438
|
-
* to
|
|
147439
|
-
*
|
|
147440
|
-
* @param {CreateKeyParams} params See {@link CreateKeyParams} for details.
|
|
147441
|
-
* @param {number} params.version did-btcr2 identifier version.
|
|
147442
|
-
* @param {string} params.network did-btcr2 bitcoin network.
|
|
147443
|
-
* @param {KeyBytes} params.pubKeyBytes public key bytes for id creation.
|
|
147444
|
-
* @returns {CreateResponse} A response object of type {@link CreateResponse}.
|
|
147445
|
-
* @throws {DidError} if the public key is missing or invalid.
|
|
147438
|
+
* Create a minimal IntermediateDidDocument with a placeholder ID.
|
|
147439
|
+
* @param {Array<DidVerificationMethod>} verificationMethod The public key in multibase format.
|
|
147440
|
+
* @param {VerificationRelationships} relationships The public key in multibase format.
|
|
147441
|
+
* @param {Array<BeaconService>} service The service to be included in the document.
|
|
147442
|
+
* @returns {IntermediateDidDocument} A new IntermediateDidDocument with the placeholder ID.
|
|
147446
147443
|
*/
|
|
147447
|
-
static
|
|
147448
|
-
const
|
|
147449
|
-
|
|
147450
|
-
|
|
147451
|
-
|
|
147452
|
-
|
|
147453
|
-
|
|
147454
|
-
|
|
147444
|
+
static create(verificationMethod, relationships, service) {
|
|
147445
|
+
const id = ID_PLACEHOLDER_VALUE;
|
|
147446
|
+
return new _IntermediateDidDocument({ id, ...relationships, verificationMethod, service });
|
|
147447
|
+
}
|
|
147448
|
+
/**
|
|
147449
|
+
* Create a minimal IntermediateDidDocument from a public key.
|
|
147450
|
+
* @param {KeyBytes} publicKey The public key in bytes format.
|
|
147451
|
+
* @returns {IntermediateDidDocument} A new IntermediateDidDocument with the placeholder ID.
|
|
147452
|
+
*/
|
|
147453
|
+
static fromPublicKey(publicKey2, network) {
|
|
147454
|
+
const pk = new CompressedSecp256k1PublicKey(publicKey2);
|
|
147455
|
+
const id = ID_PLACEHOLDER_VALUE;
|
|
147456
|
+
const service = BeaconUtils.generateBeaconService({
|
|
147457
|
+
id: `${id}#key-0`,
|
|
147458
|
+
publicKey: pk.compressed,
|
|
147455
147459
|
network: getNetwork(network),
|
|
147460
|
+
addressType: "p2pkh",
|
|
147456
147461
|
type: "SingletonBeacon"
|
|
147457
147462
|
});
|
|
147458
|
-
const
|
|
147459
|
-
|
|
147460
|
-
|
|
147461
|
-
|
|
147462
|
-
|
|
147463
|
+
const relationships = {
|
|
147464
|
+
authentication: [`${id}#key-0`],
|
|
147465
|
+
assertionMethod: [`${id}#key-0`],
|
|
147466
|
+
capabilityInvocation: [`${id}#key-0`],
|
|
147467
|
+
capabilityDelegation: [`${id}#key-0`]
|
|
147468
|
+
};
|
|
147469
|
+
const verificationMethod = [
|
|
147470
|
+
{
|
|
147471
|
+
id: `${id}#key-0`,
|
|
147463
147472
|
type: "Multikey",
|
|
147464
|
-
controller:
|
|
147465
|
-
publicKeyMultibase:
|
|
147466
|
-
}
|
|
147467
|
-
|
|
147468
|
-
|
|
147469
|
-
return { did: identifier, initialDocument };
|
|
147473
|
+
controller: id,
|
|
147474
|
+
publicKeyMultibase: pk.multibase.encoded
|
|
147475
|
+
}
|
|
147476
|
+
];
|
|
147477
|
+
return _IntermediateDidDocument.create(verificationMethod, relationships, [service]);
|
|
147470
147478
|
}
|
|
147471
147479
|
/**
|
|
147472
|
-
*
|
|
147473
|
-
*
|
|
147474
|
-
*
|
|
147475
|
-
* initial DID documents, including the ability to include Service Endpoints and Beacons that support aggregation.
|
|
147476
|
-
* Inputs include `intermediateDocument`, optional version and network returning initialDidDocument. The
|
|
147477
|
-
* intermediateDocument should be a valid DID document except all places where the DID document requires the use of
|
|
147478
|
-
* the identifier (e.g. the id field). These fields should use placeholder value
|
|
147479
|
-
* `did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`. The intermediateDocument should include at
|
|
147480
|
-
* least one verificationMethod and service of the type SingletonBeacon.
|
|
147481
|
-
*
|
|
147482
|
-
* @param {CreateExternalParams} params See {@link CreateExternalParams} for details.
|
|
147483
|
-
* @param {number} params.version Identifier version.
|
|
147484
|
-
* @param {string} params.network Identifier network name.
|
|
147485
|
-
* @param {string} params.documentBytes Intermediate DID Document bytes.
|
|
147486
|
-
* @returns {CreateResponse} A Promise resolving to {@link CreateResponses}.
|
|
147487
|
-
* @throws {DidError} if the verificationMethod or service objects are missing required properties
|
|
147480
|
+
* Taken an object, convert it to an IntermediateDocuemnt and then to a DidDocument.
|
|
147481
|
+
* @param {JSONObject} object The JSON object to convert.
|
|
147482
|
+
* @returns {DidDocument} The created DidDocument.
|
|
147488
147483
|
*/
|
|
147489
|
-
static
|
|
147490
|
-
|
|
147491
|
-
|
|
147492
|
-
|
|
147493
|
-
|
|
147494
|
-
|
|
147495
|
-
|
|
147496
|
-
return { did, initialDocument };
|
|
147484
|
+
static fromJSON(object2) {
|
|
147485
|
+
return new _IntermediateDidDocument(object2);
|
|
147486
|
+
}
|
|
147487
|
+
};
|
|
147488
|
+
var Document = class {
|
|
147489
|
+
static isValid(didDocument) {
|
|
147490
|
+
return new DidDocument2(didDocument).validateIntermediate();
|
|
147497
147491
|
}
|
|
147498
147492
|
};
|
|
147499
|
-
|
|
147500
|
-
// src/core/crud/deactivate.ts
|
|
147501
|
-
init_shim();
|
|
147502
|
-
|
|
147503
|
-
// src/did-btcr2.ts
|
|
147504
|
-
init_shim();
|
|
147505
|
-
var tinysecp4 = __toESM(require_dist2(), 1);
|
|
147506
147493
|
|
|
147507
147494
|
// src/core/crud/read.ts
|
|
147508
|
-
init_shim();
|
|
147509
147495
|
var bitcoin4 = new BitcoinNetworkConnection();
|
|
147510
147496
|
var Resolve = class {
|
|
147511
147497
|
/**
|
|
@@ -148107,7 +148093,7 @@ a=end-of-candidates
|
|
|
148107
148093
|
);
|
|
148108
148094
|
}
|
|
148109
148095
|
const id = fullId.slice(fullId.indexOf("#"));
|
|
148110
|
-
const multikey = !secretKeyMultibase ? await KeyManager.getKeyPair(fullId) : SchnorrMultikey.
|
|
148096
|
+
const multikey = !secretKeyMultibase ? await KeyManager.getKeyPair(fullId) : SchnorrMultikey.create({
|
|
148111
148097
|
id,
|
|
148112
148098
|
controller,
|
|
148113
148099
|
keys: new SchnorrKeyPair({
|
|
@@ -148204,15 +148190,9 @@ a=end-of-candidates
|
|
|
148204
148190
|
*/
|
|
148205
148191
|
static async create(params) {
|
|
148206
148192
|
const { idType, options: options2 = {} } = params;
|
|
148207
|
-
|
|
148208
|
-
|
|
148209
|
-
|
|
148210
|
-
}
|
|
148211
|
-
if (idType === IdentifierTypes.EXTERNAL) {
|
|
148212
|
-
const { intermediateDocument } = params;
|
|
148213
|
-
return await Create.external({ intermediateDocument, options: options2 });
|
|
148214
|
-
}
|
|
148215
|
-
throw new MethodError('Invalid idType: expected "KEY" or "EXTERNAL"', INVALID_DID, params);
|
|
148193
|
+
const { version: version3 = 1, network = "bitcoin" } = options2;
|
|
148194
|
+
const genesisBytes = params.genesisBytes;
|
|
148195
|
+
return Identifier.encode({ idType, genesisBytes, version: version3, network });
|
|
148216
148196
|
}
|
|
148217
148197
|
/**
|
|
148218
148198
|
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#read | 7.2 Read}.
|