@originals/sdk 1.1.0 → 1.4.2
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/package.json +3 -2
- package/src/did/DIDManager.ts +1 -1
- package/src/did/WebVHManager.ts +11 -2
- package/src/examples/create-module-original.ts +435 -0
- package/src/examples/full-lifecycle-flow.ts +514 -0
- package/src/examples/run.ts +59 -4
- package/src/index.ts +69 -3
- package/src/kinds/KindRegistry.ts +290 -0
- package/src/kinds/index.ts +74 -0
- package/src/kinds/types.ts +470 -0
- package/src/kinds/validators/AgentValidator.ts +257 -0
- package/src/kinds/validators/AppValidator.ts +211 -0
- package/src/kinds/validators/DatasetValidator.ts +242 -0
- package/src/kinds/validators/DocumentValidator.ts +311 -0
- package/src/kinds/validators/MediaValidator.ts +269 -0
- package/src/kinds/validators/ModuleValidator.ts +225 -0
- package/src/kinds/validators/base.ts +276 -0
- package/src/kinds/validators/index.ts +12 -0
- package/src/lifecycle/LifecycleManager.ts +909 -1
- package/src/resources/ResourceManager.ts +655 -0
- package/src/resources/index.ts +21 -0
- package/src/resources/types.ts +202 -0
- package/src/types/common.ts +1 -1
- package/src/vc/CredentialManager.ts +647 -2
- package/tests/integration/createTypedOriginal.test.ts +379 -0
- package/tests/performance/BatchOperations.perf.test.ts +2 -2
- package/tests/unit/kinds/KindRegistry.test.ts +329 -0
- package/tests/unit/kinds/types.test.ts +409 -0
- package/tests/unit/kinds/validators.test.ts +651 -0
- package/tests/unit/lifecycle/LifecycleManager.cleanapi.test.ts +441 -0
- package/tests/unit/resources/ResourceManager.test.ts +740 -0
- package/tests/unit/vc/CredentialManager.helpers.test.ts +527 -0
- package/tsconfig.json +0 -1
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-test.log +0 -68353
- package/dist/adapters/FeeOracleMock.d.ts +0 -6
- package/dist/adapters/FeeOracleMock.js +0 -8
- package/dist/adapters/index.d.ts +0 -4
- package/dist/adapters/index.js +0 -4
- package/dist/adapters/providers/OrdHttpProvider.d.ts +0 -56
- package/dist/adapters/providers/OrdHttpProvider.js +0 -110
- package/dist/adapters/providers/OrdMockProvider.d.ts +0 -70
- package/dist/adapters/providers/OrdMockProvider.js +0 -75
- package/dist/adapters/types.d.ts +0 -71
- package/dist/adapters/types.js +0 -1
- package/dist/bitcoin/BitcoinManager.d.ts +0 -15
- package/dist/bitcoin/BitcoinManager.js +0 -262
- package/dist/bitcoin/BroadcastClient.d.ts +0 -30
- package/dist/bitcoin/BroadcastClient.js +0 -35
- package/dist/bitcoin/OrdinalsClient.d.ts +0 -21
- package/dist/bitcoin/OrdinalsClient.js +0 -105
- package/dist/bitcoin/PSBTBuilder.d.ts +0 -24
- package/dist/bitcoin/PSBTBuilder.js +0 -80
- package/dist/bitcoin/fee-calculation.d.ts +0 -14
- package/dist/bitcoin/fee-calculation.js +0 -31
- package/dist/bitcoin/providers/OrdNodeProvider.d.ts +0 -38
- package/dist/bitcoin/providers/OrdNodeProvider.js +0 -67
- package/dist/bitcoin/providers/OrdinalsProvider.d.ts +0 -33
- package/dist/bitcoin/providers/OrdinalsProvider.js +0 -50
- package/dist/bitcoin/providers/types.d.ts +0 -63
- package/dist/bitcoin/providers/types.js +0 -1
- package/dist/bitcoin/transactions/commit.d.ts +0 -89
- package/dist/bitcoin/transactions/commit.js +0 -311
- package/dist/bitcoin/transactions/index.d.ts +0 -7
- package/dist/bitcoin/transactions/index.js +0 -8
- package/dist/bitcoin/transfer.d.ts +0 -9
- package/dist/bitcoin/transfer.js +0 -26
- package/dist/bitcoin/utxo-selection.d.ts +0 -78
- package/dist/bitcoin/utxo-selection.js +0 -237
- package/dist/bitcoin/utxo.d.ts +0 -26
- package/dist/bitcoin/utxo.js +0 -78
- package/dist/contexts/credentials-v1.json +0 -195
- package/dist/contexts/credentials-v2-examples.json +0 -5
- package/dist/contexts/credentials-v2.json +0 -301
- package/dist/contexts/credentials.json +0 -195
- package/dist/contexts/data-integrity-v2.json +0 -81
- package/dist/contexts/dids.json +0 -57
- package/dist/contexts/ed255192020.json +0 -93
- package/dist/contexts/ordinals-plus.json +0 -23
- package/dist/contexts/originals.json +0 -22
- package/dist/core/OriginalsSDK.d.ts +0 -158
- package/dist/core/OriginalsSDK.js +0 -274
- package/dist/crypto/Multikey.d.ts +0 -30
- package/dist/crypto/Multikey.js +0 -149
- package/dist/crypto/Signer.d.ts +0 -21
- package/dist/crypto/Signer.js +0 -196
- package/dist/crypto/noble-init.d.ts +0 -18
- package/dist/crypto/noble-init.js +0 -106
- package/dist/did/BtcoDidResolver.d.ts +0 -57
- package/dist/did/BtcoDidResolver.js +0 -166
- package/dist/did/DIDManager.d.ts +0 -101
- package/dist/did/DIDManager.js +0 -493
- package/dist/did/Ed25519Verifier.d.ts +0 -30
- package/dist/did/Ed25519Verifier.js +0 -59
- package/dist/did/KeyManager.d.ts +0 -17
- package/dist/did/KeyManager.js +0 -207
- package/dist/did/WebVHManager.d.ts +0 -100
- package/dist/did/WebVHManager.js +0 -304
- package/dist/did/createBtcoDidDocument.d.ts +0 -10
- package/dist/did/createBtcoDidDocument.js +0 -42
- package/dist/did/providers/OrdinalsClientProviderAdapter.d.ts +0 -23
- package/dist/did/providers/OrdinalsClientProviderAdapter.js +0 -51
- package/dist/events/EventEmitter.d.ts +0 -115
- package/dist/events/EventEmitter.js +0 -198
- package/dist/events/index.d.ts +0 -7
- package/dist/events/index.js +0 -6
- package/dist/events/types.d.ts +0 -286
- package/dist/events/types.js +0 -9
- package/dist/examples/basic-usage.d.ts +0 -3
- package/dist/examples/basic-usage.js +0 -62
- package/dist/examples/run.d.ts +0 -1
- package/dist/examples/run.js +0 -4
- package/dist/index.d.ts +0 -39
- package/dist/index.js +0 -47
- package/dist/lifecycle/BatchOperations.d.ts +0 -147
- package/dist/lifecycle/BatchOperations.js +0 -251
- package/dist/lifecycle/LifecycleManager.d.ts +0 -116
- package/dist/lifecycle/LifecycleManager.js +0 -971
- package/dist/lifecycle/OriginalsAsset.d.ts +0 -164
- package/dist/lifecycle/OriginalsAsset.js +0 -380
- package/dist/lifecycle/ProvenanceQuery.d.ts +0 -126
- package/dist/lifecycle/ProvenanceQuery.js +0 -220
- package/dist/lifecycle/ResourceVersioning.d.ts +0 -73
- package/dist/lifecycle/ResourceVersioning.js +0 -127
- package/dist/migration/MigrationManager.d.ts +0 -86
- package/dist/migration/MigrationManager.js +0 -412
- package/dist/migration/audit/AuditLogger.d.ts +0 -51
- package/dist/migration/audit/AuditLogger.js +0 -156
- package/dist/migration/checkpoint/CheckpointManager.d.ts +0 -31
- package/dist/migration/checkpoint/CheckpointManager.js +0 -96
- package/dist/migration/checkpoint/CheckpointStorage.d.ts +0 -26
- package/dist/migration/checkpoint/CheckpointStorage.js +0 -89
- package/dist/migration/index.d.ts +0 -22
- package/dist/migration/index.js +0 -27
- package/dist/migration/operations/BaseMigration.d.ts +0 -48
- package/dist/migration/operations/BaseMigration.js +0 -83
- package/dist/migration/operations/PeerToBtcoMigration.d.ts +0 -25
- package/dist/migration/operations/PeerToBtcoMigration.js +0 -67
- package/dist/migration/operations/PeerToWebvhMigration.d.ts +0 -19
- package/dist/migration/operations/PeerToWebvhMigration.js +0 -46
- package/dist/migration/operations/WebvhToBtcoMigration.d.ts +0 -25
- package/dist/migration/operations/WebvhToBtcoMigration.js +0 -67
- package/dist/migration/rollback/RollbackManager.d.ts +0 -29
- package/dist/migration/rollback/RollbackManager.js +0 -146
- package/dist/migration/state/StateMachine.d.ts +0 -25
- package/dist/migration/state/StateMachine.js +0 -76
- package/dist/migration/state/StateTracker.d.ts +0 -36
- package/dist/migration/state/StateTracker.js +0 -123
- package/dist/migration/types.d.ts +0 -306
- package/dist/migration/types.js +0 -33
- package/dist/migration/validation/BitcoinValidator.d.ts +0 -13
- package/dist/migration/validation/BitcoinValidator.js +0 -83
- package/dist/migration/validation/CredentialValidator.d.ts +0 -13
- package/dist/migration/validation/CredentialValidator.js +0 -46
- package/dist/migration/validation/DIDCompatibilityValidator.d.ts +0 -16
- package/dist/migration/validation/DIDCompatibilityValidator.js +0 -127
- package/dist/migration/validation/LifecycleValidator.d.ts +0 -10
- package/dist/migration/validation/LifecycleValidator.js +0 -52
- package/dist/migration/validation/StorageValidator.d.ts +0 -10
- package/dist/migration/validation/StorageValidator.js +0 -65
- package/dist/migration/validation/ValidationPipeline.d.ts +0 -29
- package/dist/migration/validation/ValidationPipeline.js +0 -180
- package/dist/storage/LocalStorageAdapter.d.ts +0 -11
- package/dist/storage/LocalStorageAdapter.js +0 -53
- package/dist/storage/MemoryStorageAdapter.d.ts +0 -6
- package/dist/storage/MemoryStorageAdapter.js +0 -21
- package/dist/storage/StorageAdapter.d.ts +0 -16
- package/dist/storage/StorageAdapter.js +0 -1
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js +0 -2
- package/dist/types/bitcoin.d.ts +0 -84
- package/dist/types/bitcoin.js +0 -1
- package/dist/types/common.d.ts +0 -82
- package/dist/types/common.js +0 -1
- package/dist/types/credentials.d.ts +0 -75
- package/dist/types/credentials.js +0 -1
- package/dist/types/did.d.ts +0 -26
- package/dist/types/did.js +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.js +0 -5
- package/dist/types/network.d.ts +0 -78
- package/dist/types/network.js +0 -145
- package/dist/utils/EventLogger.d.ts +0 -71
- package/dist/utils/EventLogger.js +0 -232
- package/dist/utils/Logger.d.ts +0 -106
- package/dist/utils/Logger.js +0 -257
- package/dist/utils/MetricsCollector.d.ts +0 -110
- package/dist/utils/MetricsCollector.js +0 -264
- package/dist/utils/bitcoin-address.d.ts +0 -38
- package/dist/utils/bitcoin-address.js +0 -113
- package/dist/utils/cbor.d.ts +0 -2
- package/dist/utils/cbor.js +0 -9
- package/dist/utils/encoding.d.ts +0 -37
- package/dist/utils/encoding.js +0 -120
- package/dist/utils/hash.d.ts +0 -1
- package/dist/utils/hash.js +0 -5
- package/dist/utils/retry.d.ts +0 -10
- package/dist/utils/retry.js +0 -35
- package/dist/utils/satoshi-validation.d.ts +0 -60
- package/dist/utils/satoshi-validation.js +0 -156
- package/dist/utils/serialization.d.ts +0 -14
- package/dist/utils/serialization.js +0 -76
- package/dist/utils/telemetry.d.ts +0 -17
- package/dist/utils/telemetry.js +0 -24
- package/dist/utils/validation.d.ts +0 -5
- package/dist/utils/validation.js +0 -98
- package/dist/vc/CredentialManager.d.ts +0 -22
- package/dist/vc/CredentialManager.js +0 -227
- package/dist/vc/Issuer.d.ts +0 -27
- package/dist/vc/Issuer.js +0 -70
- package/dist/vc/Verifier.d.ts +0 -16
- package/dist/vc/Verifier.js +0 -50
- package/dist/vc/cryptosuites/bbs.d.ts +0 -44
- package/dist/vc/cryptosuites/bbs.js +0 -213
- package/dist/vc/cryptosuites/bbsSimple.d.ts +0 -9
- package/dist/vc/cryptosuites/bbsSimple.js +0 -12
- package/dist/vc/cryptosuites/eddsa.d.ts +0 -30
- package/dist/vc/cryptosuites/eddsa.js +0 -81
- package/dist/vc/documentLoader.d.ts +0 -16
- package/dist/vc/documentLoader.js +0 -59
- package/dist/vc/proofs/data-integrity.d.ts +0 -21
- package/dist/vc/proofs/data-integrity.js +0 -15
- package/dist/vc/utils/jsonld.d.ts +0 -2
- package/dist/vc/utils/jsonld.js +0 -15
- package/test/logs/did_webvh_QmQsRNhXxPSCSeLjpbKYcNMZj8b1kBQAoC6cZmkFAgmpHt_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmSQkpD58qxcqMWHYcEmDUn3wk7hHvJwzYTrZmhh6zjPQ8_example_com_users_alice123_profile.jsonl +0 -1
- package/test/logs/did_webvh_QmTMda6VW3cUPdKk5Yc3onnv1vdgEumvWWdP2noAYFSjeG_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmTkb8KnCYcsnKKDCY4eUQuKQdKJLrCinvhw13v3zETxpE_example_com_users_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmTn9FdCfpXFDrxHH52pwB4iNrDFVvNDjJ5FQTcDbmM3Fg_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmUCQUi1xjtJjnSQ1XJZgKqcWgErx1v7E2dz4DAPraAyJP_example_com_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmUENQJCDKBJVRS5BkL6zjaUvcRjkb9xHmy7foCgRjmv3W_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmUPdGyjYBEnQ3aQUkmqyyBKTyjvCP5RZQGiaEDeTtf6dc_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmUoHTuHMWzQM29ZFrE9VLtMxkZ5u869yqee8LwcCLN39M_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmUrnms8G65ggVKsr9oQeWrLUBuGChwQPPb2LCFvaoNxaw_example_com_users_alice.jsonl +0 -1
- package/test/logs/did_webvh_QmUwiw3eSXdHG1hPvoAGu3cuK5jF4aXRYDLBAjPXfv1qzb_example_com_level1_level2.jsonl +0 -1
- package/test/logs/did_webvh_QmW7bzKh6yFEKNAtmVsrPGvvsMHTUQdzJSNsTZkbuGFpbj_example_com_secret.jsonl +0 -1
- package/test/logs/did_webvh_QmXbFTFBBJ8zpjdz9WE1DNN44A2wprFmdvAubjSffeyoAG_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmXyVXFPCTffGb2mTUFDeMCsScjnpLWkyUkVkB6q6QoeBf_example_com_C_Windows_System32.jsonl +0 -1
- package/test/logs/did_webvh_QmZK9B81gxZtvo5fYHYKDtKt8zZfZZPhmCMhbujBJuRRzE_example_com_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmbNLCVSdXSVLrwFBvCBQPAabjtRb1SGHjkGVyw3QUbfBL_example_com_users_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmbeaicmGW3Q7Yzbqmftc8a9jLBngokveb5A2KVKfVGZRb_example_com_my_org_user_name_test_123.jsonl +0 -1
- package/test/logs/did_webvh_Qmdv7c7AjUreUfoKyvkN2UpAWTozxKsv99srQetPJMJEnp_example_com_users_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmeioWY3uypYLkYpCXe9eCYnn4xBVruP9C1d79azMrTEHG_example_com.jsonl +0 -1
- package/test/logs/did_webvh_Qmf4QH5dsA6Ecr5HJ6KaJL9uJRyY8RxrQdqoRCM25DzvPi_example_com_users_alice.jsonl +0 -1
- package/tests/e2e/README.md +0 -97
- package/tests/e2e/example.spec.ts +0 -78
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
export class BtcoDidResolver {
|
|
2
|
-
constructor(options = {}) {
|
|
3
|
-
this.options = options;
|
|
4
|
-
}
|
|
5
|
-
parseBtcoDid(did) {
|
|
6
|
-
const regex = /^did:btco(?::(reg|sig))?:([0-9]+)(?:\/(.+))?$/;
|
|
7
|
-
const match = did.match(regex);
|
|
8
|
-
if (!match)
|
|
9
|
-
return null;
|
|
10
|
-
const [, networkSuffix, satNumber, path] = match;
|
|
11
|
-
const network = networkSuffix || 'mainnet';
|
|
12
|
-
return { satNumber, path, network };
|
|
13
|
-
}
|
|
14
|
-
getDidPrefix(network) {
|
|
15
|
-
switch (network) {
|
|
16
|
-
case 'reg':
|
|
17
|
-
case 'regtest':
|
|
18
|
-
return 'did:btco:reg';
|
|
19
|
-
case 'sig':
|
|
20
|
-
case 'signet':
|
|
21
|
-
return 'did:btco:sig';
|
|
22
|
-
default:
|
|
23
|
-
return 'did:btco';
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async resolve(did, options = {}) {
|
|
27
|
-
const parsed = this.parseBtcoDid(did);
|
|
28
|
-
if (!parsed) {
|
|
29
|
-
return this.createErrorResult('invalidDid', `Invalid BTCO DID format: ${did}`);
|
|
30
|
-
}
|
|
31
|
-
const { satNumber, network } = parsed;
|
|
32
|
-
const provider = options.provider || this.options.provider;
|
|
33
|
-
if (!provider) {
|
|
34
|
-
return this.createErrorResult('noProvider', 'No provider supplied');
|
|
35
|
-
}
|
|
36
|
-
let inscriptionIds = [];
|
|
37
|
-
try {
|
|
38
|
-
const satInfo = await provider.getSatInfo(satNumber);
|
|
39
|
-
inscriptionIds = satInfo?.inscription_ids || [];
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
return this.createErrorResult('notFound', `Failed to retrieve inscriptions for satoshi ${satNumber}: ${e?.message || String(e)}`);
|
|
43
|
-
}
|
|
44
|
-
if (inscriptionIds.length === 0) {
|
|
45
|
-
return this.createErrorResult('notFound', `No inscriptions found on satoshi ${satNumber}`);
|
|
46
|
-
}
|
|
47
|
-
const expectedDid = `${this.getDidPrefix(network)}:${satNumber}`;
|
|
48
|
-
const didPattern = new RegExp(`^(?:BTCO DID: )?(${expectedDid.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'i');
|
|
49
|
-
const inscriptionDataList = [];
|
|
50
|
-
for (const inscriptionId of inscriptionIds) {
|
|
51
|
-
const inscriptionData = {
|
|
52
|
-
inscriptionId,
|
|
53
|
-
content: '',
|
|
54
|
-
metadata: null
|
|
55
|
-
};
|
|
56
|
-
try {
|
|
57
|
-
const inscription = await provider.resolveInscription(inscriptionId);
|
|
58
|
-
if (!inscription) {
|
|
59
|
-
inscriptionData.error = `Inscription ${inscriptionId} not found`;
|
|
60
|
-
inscriptionDataList.push(inscriptionData);
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
inscriptionData.contentUrl = inscription.content_url;
|
|
64
|
-
inscriptionData.contentType = inscription.content_type;
|
|
65
|
-
try {
|
|
66
|
-
// Use configurable fetch function or default to global fetch
|
|
67
|
-
const fetchFn = options.fetchFn || this.options.fetchFn || fetch;
|
|
68
|
-
const timeout = options.timeout || this.options.timeout || 10000; // 10 second default
|
|
69
|
-
// Create abort controller for timeout
|
|
70
|
-
const controller = new AbortController();
|
|
71
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
72
|
-
try {
|
|
73
|
-
const response = await fetchFn(inscription.content_url);
|
|
74
|
-
clearTimeout(timeoutId);
|
|
75
|
-
if (!response.ok) {
|
|
76
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
77
|
-
}
|
|
78
|
-
inscriptionData.content = await response.text();
|
|
79
|
-
}
|
|
80
|
-
finally {
|
|
81
|
-
clearTimeout(timeoutId);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
inscriptionData.error = `Failed to fetch content: ${err?.message || String(err)}`;
|
|
86
|
-
inscriptionDataList.push(inscriptionData);
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
inscriptionData.metadata = await provider.getMetadata(inscriptionId);
|
|
91
|
-
}
|
|
92
|
-
catch (err) {
|
|
93
|
-
inscriptionData.metadata = null;
|
|
94
|
-
}
|
|
95
|
-
inscriptionData.isValidDid = didPattern.test(inscriptionData.content);
|
|
96
|
-
if (inscriptionData.isValidDid && inscriptionData.metadata) {
|
|
97
|
-
const didDocument = inscriptionData.metadata;
|
|
98
|
-
if (this.isValidDidDocument(didDocument) && didDocument.id === expectedDid) {
|
|
99
|
-
inscriptionData.didDocument = didDocument;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
inscriptionData.error = 'Invalid DID document structure or mismatched ID';
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (inscriptionData.content.includes('🔥')) {
|
|
106
|
-
inscriptionData.didDocument = null;
|
|
107
|
-
if (!inscriptionData.error) {
|
|
108
|
-
inscriptionData.error = 'DID has been deactivated';
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
inscriptionData.error = `Failed to process inscription: ${err?.message || String(err)}`;
|
|
114
|
-
}
|
|
115
|
-
inscriptionDataList.push(inscriptionData);
|
|
116
|
-
}
|
|
117
|
-
let latestValidDidDocument = null;
|
|
118
|
-
let latestInscriptionId;
|
|
119
|
-
for (let i = inscriptionDataList.length - 1; i >= 0; i--) {
|
|
120
|
-
const data = inscriptionDataList[i];
|
|
121
|
-
if (data.didDocument && !data.error) {
|
|
122
|
-
latestValidDidDocument = data.didDocument;
|
|
123
|
-
latestInscriptionId = data.inscriptionId;
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
didDocument: latestValidDidDocument,
|
|
129
|
-
inscriptions: inscriptionDataList,
|
|
130
|
-
resolutionMetadata: {
|
|
131
|
-
inscriptionId: latestInscriptionId,
|
|
132
|
-
satNumber,
|
|
133
|
-
network,
|
|
134
|
-
totalInscriptions: inscriptionDataList.length
|
|
135
|
-
},
|
|
136
|
-
didDocumentMetadata: {
|
|
137
|
-
inscriptionId: latestInscriptionId,
|
|
138
|
-
network
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
isValidDidDocument(doc) {
|
|
143
|
-
if (!doc || typeof doc !== 'object')
|
|
144
|
-
return false;
|
|
145
|
-
if (!doc.id || typeof doc.id !== 'string')
|
|
146
|
-
return false;
|
|
147
|
-
if (!doc['@context'])
|
|
148
|
-
return false;
|
|
149
|
-
const contexts = Array.isArray(doc['@context']) ? doc['@context'] : [doc['@context']];
|
|
150
|
-
if (!contexts.includes('https://www.w3.org/ns/did/v1') && !contexts.includes('https://w3id.org/did/v1')) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
if (doc.verificationMethod && !Array.isArray(doc.verificationMethod))
|
|
154
|
-
return false;
|
|
155
|
-
if (doc.authentication && !Array.isArray(doc.authentication))
|
|
156
|
-
return false;
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
createErrorResult(error, message) {
|
|
160
|
-
return {
|
|
161
|
-
didDocument: null,
|
|
162
|
-
resolutionMetadata: { error, message },
|
|
163
|
-
didDocumentMetadata: {}
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
}
|
package/dist/did/DIDManager.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { DIDDocument, OriginalsConfig, AssetResource, KeyPair, ExternalSigner, ExternalVerifier } from '../types';
|
|
2
|
-
import { createBtcoDidDocument } from './createBtcoDidDocument';
|
|
3
|
-
export declare class DIDManager {
|
|
4
|
-
private config;
|
|
5
|
-
constructor(config: OriginalsConfig);
|
|
6
|
-
createDIDPeer(resources: AssetResource[], returnKeyPair?: false): Promise<DIDDocument>;
|
|
7
|
-
createDIDPeer(resources: AssetResource[], returnKeyPair: true): Promise<{
|
|
8
|
-
didDocument: DIDDocument;
|
|
9
|
-
keyPair: {
|
|
10
|
-
privateKey: string;
|
|
11
|
-
publicKey: string;
|
|
12
|
-
};
|
|
13
|
-
}>;
|
|
14
|
-
migrateToDIDWebVH(didDoc: DIDDocument, domain?: string): Promise<DIDDocument>;
|
|
15
|
-
migrateToDIDBTCO(didDoc: DIDDocument, satoshi: string): Promise<DIDDocument>;
|
|
16
|
-
resolveDID(did: string): Promise<DIDDocument | null>;
|
|
17
|
-
validateDIDDocument(didDoc: DIDDocument): boolean;
|
|
18
|
-
private getLayerFromDID;
|
|
19
|
-
createBtcoDidDocument(satNumber: number | string, network: 'mainnet' | 'regtest' | 'signet', options: Parameters<typeof createBtcoDidDocument>[2]): DIDDocument;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new did:webvh DID with proper cryptographic signing
|
|
22
|
-
* @param options - Creation options including domain and optional key pair or external signer
|
|
23
|
-
* @returns The created DID, document, log, and key pair (if generated)
|
|
24
|
-
*/
|
|
25
|
-
createDIDWebVH(options: CreateWebVHOptions): Promise<CreateWebVHResult>;
|
|
26
|
-
/**
|
|
27
|
-
* Updates a DID:WebVH document
|
|
28
|
-
* @param options - Update options
|
|
29
|
-
* @returns Updated DID document and log
|
|
30
|
-
*/
|
|
31
|
-
updateDIDWebVH(options: {
|
|
32
|
-
did: string;
|
|
33
|
-
currentLog: DIDLog;
|
|
34
|
-
updates: Partial<DIDDocument>;
|
|
35
|
-
signer: ExternalSigner | {
|
|
36
|
-
privateKey: string;
|
|
37
|
-
publicKey: string;
|
|
38
|
-
};
|
|
39
|
-
verifier?: ExternalVerifier;
|
|
40
|
-
outputDir?: string;
|
|
41
|
-
}): Promise<{
|
|
42
|
-
didDocument: DIDDocument;
|
|
43
|
-
log: DIDLog;
|
|
44
|
-
logPath?: string;
|
|
45
|
-
}>;
|
|
46
|
-
/**
|
|
47
|
-
* Saves the DID log to the appropriate did.jsonl path
|
|
48
|
-
* @param did - The DID identifier
|
|
49
|
-
* @param log - The DID log to save
|
|
50
|
-
* @param baseDir - Base directory for saving (e.g., public/.well-known)
|
|
51
|
-
* @returns The full path where the log was saved
|
|
52
|
-
*/
|
|
53
|
-
saveDIDLog(did: string, log: DIDLog, baseDir: string): Promise<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Loads a DID log from a did.jsonl file
|
|
56
|
-
* @param logPath - Path to the did.jsonl file
|
|
57
|
-
* @returns The loaded DID log
|
|
58
|
-
*/
|
|
59
|
-
loadDIDLog(logPath: string): Promise<DIDLog>;
|
|
60
|
-
/**
|
|
61
|
-
* Validates a path segment to prevent directory traversal attacks
|
|
62
|
-
* @param segment - Path segment to validate
|
|
63
|
-
* @returns true if valid, false otherwise
|
|
64
|
-
*/
|
|
65
|
-
private isValidPathSegment;
|
|
66
|
-
}
|
|
67
|
-
interface WebVHVerificationMethod {
|
|
68
|
-
id?: string;
|
|
69
|
-
type: string;
|
|
70
|
-
controller?: string;
|
|
71
|
-
publicKeyMultibase: string;
|
|
72
|
-
secretKeyMultibase?: string;
|
|
73
|
-
purpose?: 'authentication' | 'assertionMethod' | 'keyAgreement' | 'capabilityInvocation' | 'capabilityDelegation';
|
|
74
|
-
}
|
|
75
|
-
interface DIDLogEntry {
|
|
76
|
-
versionId: string;
|
|
77
|
-
versionTime: string;
|
|
78
|
-
parameters: Record<string, unknown>;
|
|
79
|
-
state: Record<string, unknown>;
|
|
80
|
-
proof?: Record<string, unknown>[];
|
|
81
|
-
}
|
|
82
|
-
type DIDLog = DIDLogEntry[];
|
|
83
|
-
export interface CreateWebVHOptions {
|
|
84
|
-
domain?: string;
|
|
85
|
-
keyPair?: KeyPair;
|
|
86
|
-
paths?: string[];
|
|
87
|
-
portable?: boolean;
|
|
88
|
-
outputDir?: string;
|
|
89
|
-
externalSigner?: ExternalSigner;
|
|
90
|
-
externalVerifier?: ExternalVerifier;
|
|
91
|
-
verificationMethods?: WebVHVerificationMethod[];
|
|
92
|
-
updateKeys?: string[];
|
|
93
|
-
}
|
|
94
|
-
export interface CreateWebVHResult {
|
|
95
|
-
did: string;
|
|
96
|
-
didDocument: DIDDocument;
|
|
97
|
-
log: DIDLog;
|
|
98
|
-
keyPair: KeyPair;
|
|
99
|
-
logPath?: string;
|
|
100
|
-
}
|
|
101
|
-
export {};
|