@arcblock/did 1.32.2 → 1.32.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/esm/did-domain-resolver.d.mts +47 -2
- package/esm/did-domain-resolver.mjs +382 -34
- package/esm/index.d.mts +2 -2
- package/esm/index.mjs +2 -2
- package/lib/did-domain-resolver.cjs +384 -33
- package/lib/did-domain-resolver.d.cts +47 -2
- package/lib/index.cjs +3 -0
- package/lib/index.d.cts +2 -2
- package/package.json +3 -3
|
@@ -24,6 +24,12 @@ type DnsDidLabelEncoding = 'base36' | 'hex';
|
|
|
24
24
|
* - `'hex'`: `f` + 52 lowercase hex chars (53 chars total, <= 63 DNS limit)
|
|
25
25
|
* - For 20-byte Ethereum DIDs (`0x...`): `e` + 31 base36 chars (or `0x` + 40 hex chars).
|
|
26
26
|
*/
|
|
27
|
+
/**
|
|
28
|
+
* Strict RFC 1035 / RFC 1123 DNS hostname validator (`1..253` chars, labels `1..63` matching
|
|
29
|
+
* `/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i`, zero wildcards `*`, ports `:`, slashes `/`,
|
|
30
|
+
* underscores `_`, percent-escapes `%`, IPv4 literals, or numeric-only TLDs).
|
|
31
|
+
*/
|
|
32
|
+
declare function isValidStrictDnsHostname(host: string): boolean;
|
|
27
33
|
declare function toDnsDidLabel(did: string, encoding?: DnsDidLabelEncoding): string;
|
|
28
34
|
/**
|
|
29
35
|
* Decode a DNS subdomain label (or raw DID string) back into a canonical,
|
|
@@ -36,12 +42,26 @@ declare function toDnsDidLabel(did: string, encoding?: DnsDidLabelEncoding): str
|
|
|
36
42
|
* - Case-preserved raw Base58btc DID (`z...`) when routed via Cloudflare Worker paths/headers
|
|
37
43
|
*/
|
|
38
44
|
declare function fromDnsDidLabel(label: string, method?: DIDMethod): string;
|
|
45
|
+
/**
|
|
46
|
+
* Losslessly encode a W3C/OCAP DID into lowercase RFC 1035 DNS labels (`<= 63` chars per label)
|
|
47
|
+
* using unpadded RFC 4648 base32 (`d0-<b32>` single-label or `d0.<chunk1>.<chunk2>...` multi-label),
|
|
48
|
+
* matching `ArcBlock/arc` `encodeDidForDnsLabels` 1:1 (#2025).
|
|
49
|
+
*/
|
|
50
|
+
declare function encodeDidForDnsLabels(did: string, defaultMethod?: DIDMethod): string;
|
|
51
|
+
/**
|
|
52
|
+
* Decode DNS label(s) back into a canonical, checksum-verified DID (`did:<method>:...`).
|
|
53
|
+
* Supports all cross-repo `ArcBlock/arc` & `@arcblock/did` encodings:
|
|
54
|
+
* - `d0.<base32chunk1>.<base32chunk2>...` and `d0-<base32>` (`ArcBlock/arc` base32 UTF-8 DID)
|
|
55
|
+
* - `did-<method>-<id>` and `<method>.<id>`
|
|
56
|
+
* - `k<41-char-base36>`, `f<52-char-hex>`, `e<31-char-base36>`, and case-preserved `z1...`/`0x...`
|
|
57
|
+
*/
|
|
58
|
+
declare function decodeDidFromDnsLabels(prefix: string, defaultMethod?: DIDMethod): string | null;
|
|
39
59
|
/**
|
|
40
60
|
* Format the canonical DID Domain hostname (`<label>.did.abtnet.io`).
|
|
41
61
|
*/
|
|
42
62
|
declare function toDidDomainHost(did: string, gatewayDomain?: string, encoding?: DnsDidLabelEncoding): string;
|
|
43
63
|
/**
|
|
44
|
-
* Extract and verify the canonical DID from a `<label>.did.abtnet.io` hostname.
|
|
64
|
+
* Extract and verify the canonical DID from a `<label>.did.abtnet.io` (or `d0.<chunks>.did.abtnet.io`) hostname.
|
|
45
65
|
*/
|
|
46
66
|
declare function extractDidFromDomainHost(hostname: string, gatewayDomain?: string, method?: DIDMethod): string | null;
|
|
47
67
|
/**
|
|
@@ -344,6 +364,20 @@ interface ThreeTierResolutionResult {
|
|
|
344
364
|
/** Resolution trace across the 3 tiers */
|
|
345
365
|
trace: string[];
|
|
346
366
|
}
|
|
367
|
+
type DidTlsResolutionTier = 'direct-did' | 'wildcard-fallback' | 'custom-domain-nft' | 'name-registry';
|
|
368
|
+
interface ResolveDidTlsTargetOptions {
|
|
369
|
+
nftAssetState?: DomainNftAssetSnapshot;
|
|
370
|
+
keyRotationEvents?: KeyRotationEvent[];
|
|
371
|
+
now?: number;
|
|
372
|
+
}
|
|
373
|
+
interface DidTlsTargetResolution {
|
|
374
|
+
targetDid: string;
|
|
375
|
+
activePublicKeyHex: string | null;
|
|
376
|
+
cnameTargetDidDomain: string;
|
|
377
|
+
endpointUrl: string | null;
|
|
378
|
+
resolutionTier: DidTlsResolutionTier;
|
|
379
|
+
trace: string[];
|
|
380
|
+
}
|
|
347
381
|
declare function encodeDidEndpointDigest(params: {
|
|
348
382
|
did: string;
|
|
349
383
|
endpointUrl: string;
|
|
@@ -390,6 +424,7 @@ declare class DIDDomainEdgeRouter implements NameRegistry {
|
|
|
390
424
|
private bindingsByDomain;
|
|
391
425
|
private nftStateByDomain;
|
|
392
426
|
private endpointsByDidAddr;
|
|
427
|
+
private kelByDidAddr;
|
|
393
428
|
private simpleNameMap;
|
|
394
429
|
constructor(options?: {
|
|
395
430
|
gatewayDomain?: string;
|
|
@@ -436,9 +471,19 @@ declare class DIDDomainEdgeRouter implements NameRegistry {
|
|
|
436
471
|
*/
|
|
437
472
|
resolveThreeTier(queryInput: string, options?: {
|
|
438
473
|
nftAssetState?: DomainNftAssetSnapshot;
|
|
474
|
+
keyRotationEvents?: KeyRotationEvent[];
|
|
439
475
|
now?: number;
|
|
440
476
|
}): ThreeTierResolutionResult | null;
|
|
441
477
|
private _buildResult;
|
|
478
|
+
/**
|
|
479
|
+
* Resolve any URL (`https://...`, `wss://...`, `afs://...`), `<did>.arc`, `<label>.did.abtnet.io`,
|
|
480
|
+
* `did:abt:...`, `did:name:...`, or custom DNS-NFT domain into a zero-CA `DID-TLS` target identity
|
|
481
|
+
* (`targetDid`, active Ed25519/KEL public key, Tier-2 CNAME domain, and physical endpoint URL).
|
|
482
|
+
*
|
|
483
|
+
* Fails closed (`null`) on malformed/credentialed URLs, invalid `.arc` DID hosts, expired/sold DNS-NFT bindings,
|
|
484
|
+
* or broken KEL chains.
|
|
485
|
+
*/
|
|
486
|
+
resolveDidTlsTarget(input: string, options?: ResolveDidTlsTargetOptions): DidTlsTargetResolution | null;
|
|
442
487
|
resolve(name: string): string | null;
|
|
443
488
|
register(name: string, did: string): void;
|
|
444
489
|
unregister(name: string): void;
|
|
@@ -447,4 +492,4 @@ declare class DIDDomainEdgeRouter implements NameRegistry {
|
|
|
447
492
|
clear(): void;
|
|
448
493
|
}
|
|
449
494
|
//#endregion
|
|
450
|
-
export { AccountPreRotationStateData, DEFAULT_DID_DOMAIN_GATEWAY, DIDDomainEdgeRouter, DIDServiceEndpoint, DID_ENDPOINT_DOMAIN_TAG, DNS_NFT_BINDING_DOMAIN_TAG, DidEndpointRecord, DnsDidLabelEncoding, DomainNftAssetSnapshot, DomainNftBindingProof, KEY_ROTATION_DOMAIN_TAG, KeyRotationEvent, MAX_CUSTOM_DOMAINS_PER_DID, MAX_ROTATION_CHAIN_LENGTH, PRE_ROTATION_DOMAIN_TAG, SynthesizeDidDocumentOptions, ThreeTierResolutionResult, W3CDIDDocument, W3CDIDVerificationMethod, createAccountMigratePreRotationData, createDomainNftBindingProof, createKeyRotationEvent, createPreRotationCommitment, encodeDidEndpointDigest, extractAccountPreRotationData, extractDidFromDomainHost, fromDnsDidLabel, isValidPreRotationCommitment, normalizePreRotationCommitment, normalizePublicKeyHex, synthesizeDidDocument, toDidDomainHost, toDidWellKnownUrl, toDnsDidLabel, verifyAccountMigrationChainWithKel, verifyDomainNftBindingProof, verifyKeyRotationChain, verifyPreRotationCommitment, verifySingleKeyRotationEvent };
|
|
495
|
+
export { AccountPreRotationStateData, DEFAULT_DID_DOMAIN_GATEWAY, DIDDomainEdgeRouter, DIDServiceEndpoint, DID_ENDPOINT_DOMAIN_TAG, DNS_NFT_BINDING_DOMAIN_TAG, DidEndpointRecord, DidTlsResolutionTier, DidTlsTargetResolution, DnsDidLabelEncoding, DomainNftAssetSnapshot, DomainNftBindingProof, KEY_ROTATION_DOMAIN_TAG, KeyRotationEvent, MAX_CUSTOM_DOMAINS_PER_DID, MAX_ROTATION_CHAIN_LENGTH, PRE_ROTATION_DOMAIN_TAG, ResolveDidTlsTargetOptions, SynthesizeDidDocumentOptions, ThreeTierResolutionResult, W3CDIDDocument, W3CDIDVerificationMethod, createAccountMigratePreRotationData, createDomainNftBindingProof, createKeyRotationEvent, createPreRotationCommitment, decodeDidFromDnsLabels, encodeDidEndpointDigest, encodeDidForDnsLabels, extractAccountPreRotationData, extractDidFromDomainHost, fromDnsDidLabel, isValidPreRotationCommitment, isValidStrictDnsHostname, normalizePreRotationCommitment, normalizePublicKeyHex, synthesizeDidDocument, toDidDomainHost, toDidWellKnownUrl, toDnsDidLabel, verifyAccountMigrationChainWithKel, verifyDomainNftBindingProof, verifyKeyRotationChain, verifyPreRotationCommitment, verifySingleKeyRotationEvent };
|
package/lib/index.cjs
CHANGED
|
@@ -131,9 +131,11 @@ exports.createAccountMigratePreRotationData = require_did_domain_resolver.create
|
|
|
131
131
|
exports.createDomainNftBindingProof = require_did_domain_resolver.createDomainNftBindingProof;
|
|
132
132
|
exports.createKeyRotationEvent = require_did_domain_resolver.createKeyRotationEvent;
|
|
133
133
|
exports.createPreRotationCommitment = require_did_domain_resolver.createPreRotationCommitment;
|
|
134
|
+
exports.decodeDidFromDnsLabels = require_did_domain_resolver.decodeDidFromDnsLabels;
|
|
134
135
|
exports.deriveSubAccountAddress = deriveSubAccountAddress;
|
|
135
136
|
exports.deriveSubAccountSeed = require_subaccount.deriveSubAccountSeed;
|
|
136
137
|
exports.encodeDidEndpointDigest = require_did_domain_resolver.encodeDidEndpointDigest;
|
|
138
|
+
exports.encodeDidForDnsLabels = require_did_domain_resolver.encodeDidForDnsLabels;
|
|
137
139
|
exports.encodeLengthPrefixedTuple = require_subaccount.encodeLengthPrefixedTuple;
|
|
138
140
|
exports.expandShortForm = require_short_form.expandShortForm;
|
|
139
141
|
exports.extractAccountPreRotationData = require_did_domain_resolver.extractAccountPreRotationData;
|
|
@@ -162,6 +164,7 @@ exports.isLocalName = require_name.isLocalName;
|
|
|
162
164
|
exports.isSameEntity = require_entity.isSameEntity;
|
|
163
165
|
exports.isValid = isValid;
|
|
164
166
|
exports.isValidPreRotationCommitment = require_did_domain_resolver.isValidPreRotationCommitment;
|
|
167
|
+
exports.isValidStrictDnsHostname = require_did_domain_resolver.isValidStrictDnsHostname;
|
|
165
168
|
exports.normalizeName = require_name.normalizeName;
|
|
166
169
|
exports.normalizePreRotationCommitment = require_did_domain_resolver.normalizePreRotationCommitment;
|
|
167
170
|
exports.normalizePublicKeyHex = require_did_domain_resolver.normalizePublicKeyHex;
|
package/lib/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ALIAS_METHODS, ALL_METHODS, AliasMethod, CRYPTO_METHODS, CryptoMethod, DEFAULT_METHOD, DIDMethod, isAliasMethod, isCryptoMethod, isKnownMethod } from "./method.cjs";
|
|
2
2
|
import { InMemoryNameRegistry, NameRegistry } from "./name-registry.cjs";
|
|
3
|
-
import { AccountPreRotationStateData, DEFAULT_DID_DOMAIN_GATEWAY, DIDDomainEdgeRouter, DIDServiceEndpoint, DID_ENDPOINT_DOMAIN_TAG, DNS_NFT_BINDING_DOMAIN_TAG, DidEndpointRecord, DnsDidLabelEncoding, DomainNftAssetSnapshot, DomainNftBindingProof, KEY_ROTATION_DOMAIN_TAG, KeyRotationEvent, MAX_CUSTOM_DOMAINS_PER_DID, MAX_ROTATION_CHAIN_LENGTH, PRE_ROTATION_DOMAIN_TAG, SynthesizeDidDocumentOptions, ThreeTierResolutionResult, W3CDIDDocument, W3CDIDVerificationMethod, createAccountMigratePreRotationData, createDomainNftBindingProof, createKeyRotationEvent, createPreRotationCommitment, encodeDidEndpointDigest, extractAccountPreRotationData, extractDidFromDomainHost, fromDnsDidLabel, isValidPreRotationCommitment, normalizePreRotationCommitment, normalizePublicKeyHex, synthesizeDidDocument, toDidDomainHost, toDidWellKnownUrl, toDnsDidLabel, verifyAccountMigrationChainWithKel, verifyDomainNftBindingProof, verifyKeyRotationChain, verifyPreRotationCommitment, verifySingleKeyRotationEvent } from "./did-domain-resolver.cjs";
|
|
3
|
+
import { AccountPreRotationStateData, DEFAULT_DID_DOMAIN_GATEWAY, DIDDomainEdgeRouter, DIDServiceEndpoint, DID_ENDPOINT_DOMAIN_TAG, DNS_NFT_BINDING_DOMAIN_TAG, DidEndpointRecord, DidTlsResolutionTier, DidTlsTargetResolution, DnsDidLabelEncoding, DomainNftAssetSnapshot, DomainNftBindingProof, KEY_ROTATION_DOMAIN_TAG, KeyRotationEvent, MAX_CUSTOM_DOMAINS_PER_DID, MAX_ROTATION_CHAIN_LENGTH, PRE_ROTATION_DOMAIN_TAG, ResolveDidTlsTargetOptions, SynthesizeDidDocumentOptions, ThreeTierResolutionResult, W3CDIDDocument, W3CDIDVerificationMethod, createAccountMigratePreRotationData, createDomainNftBindingProof, createKeyRotationEvent, createPreRotationCommitment, decodeDidFromDnsLabels, encodeDidEndpointDigest, encodeDidForDnsLabels, extractAccountPreRotationData, extractDidFromDomainHost, fromDnsDidLabel, isValidPreRotationCommitment, isValidStrictDnsHostname, normalizePreRotationCommitment, normalizePublicKeyHex, synthesizeDidDocument, toDidDomainHost, toDidWellKnownUrl, toDnsDidLabel, verifyAccountMigrationChainWithKel, verifyDomainNftBindingProof, verifyKeyRotationChain, verifyPreRotationCommitment, verifySingleKeyRotationEvent } from "./did-domain-resolver.cjs";
|
|
4
4
|
import { getEntityId, isSameEntity } from "./entity.cjs";
|
|
5
5
|
import { DIDType, DIDTypeArg, DIDTypeShortcut, DIDTypeStr, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DidType, RequiredDIDType, fromTypeInfo, isEthereumDid, isEthereumType, toChecksumAddress, toTypeInfo, toTypeInfoStr } from "./type.cjs";
|
|
6
6
|
import { DID_PREFIX, toStrictHex } from "./util.cjs";
|
|
@@ -68,4 +68,4 @@ declare const isFromPublicKey: (did: string, pk: BytesType) => boolean;
|
|
|
68
68
|
declare const isValid: (did: string) => boolean;
|
|
69
69
|
declare const deriveSubAccountAddress: (parentIdentity: BytesType, scope: string, index?: number, type?: DIDTypeArg) => string, isFromSubAccount: (subAccountDid: string, parentIdentity: BytesType, scope: string, index?: number) => boolean;
|
|
70
70
|
//#endregion
|
|
71
|
-
export { ALIAS_METHODS, ALL_METHODS, type AccountPreRotationStateData, type AliasMethod, CRYPTO_METHODS, type CryptoMethod, DEFAULT_DID_DOMAIN_GATEWAY, DEFAULT_METHOD, DIDDomainEdgeRouter, type DIDMethod, DIDNameResolver, type DIDNameResolverOptions, type DIDServiceEndpoint, type DIDType, type DIDTypeArg, type DIDTypeShortcut, type DIDTypeStr, DID_ENDPOINT_DOMAIN_TAG, DID_PREFIX, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DNS_NFT_BINDING_DOMAIN_TAG, type DidEndpointRecord, DidType, type DnsDidLabelEncoding, type DomainNftAssetSnapshot, type DomainNftBindingProof, InMemoryNameRegistry, KEY_ROTATION_DOMAIN_TAG, type KeyRotationEvent, MAX_CUSTOM_DOMAINS_PER_DID, MAX_ROTATION_CHAIN_LENGTH, type NameHierarchy, type NameRegistry, PRE_ROTATION_DOMAIN_TAG, type ParsedDID, type RequiredDIDType, type ResolveRoute, type ResolveTraceResult, SUBACCOUNT_DOMAIN_TAG, type SynthesizeDidDocumentOptions, type ThreeTierResolutionResult, type W3CDIDDocument, type W3CDIDVerificationMethod, createAccountMigratePreRotationData, createDomainNftBindingProof, createKeyRotationEvent, createPreRotationCommitment, deriveSubAccountAddress, deriveSubAccountSeed, encodeDidEndpointDigest, encodeLengthPrefixedTuple, expandShortForm, extractAccountPreRotationData, extractDidFromDomainHost, extractIdentifier, extractMethod, formatDid, fromDnsDidLabel, fromHash, fromPublicKey, fromPublicKeyHash, fromSecretKey, fromTypeInfo, getEntityId, getResolveRoute, isAliasMethod, isCryptoMethod, isEthereumDid, isEthereumType, isFromPublicKey, isFromSubAccount, isGlobalName, isKnownDid, isKnownMethod, isLocalName, isSameEntity, isValid, isValidPreRotationCommitment, normalizeName, normalizePreRotationCommitment, normalizePublicKeyHex, parse, parseNameHierarchy, synthesizeDidDocument, toAddress, toChecksumAddress, toDid, toDidDomainHost, toDidWellKnownUrl, toDnsDidLabel, toShortForm, toStrictHex, toTypeInfo, toTypeInfoStr, types, verifyAccountMigrationChainWithKel, verifyDomainNftBindingProof, verifyKeyRotationChain, verifyPreRotationCommitment, verifySingleKeyRotationEvent };
|
|
71
|
+
export { ALIAS_METHODS, ALL_METHODS, type AccountPreRotationStateData, type AliasMethod, CRYPTO_METHODS, type CryptoMethod, DEFAULT_DID_DOMAIN_GATEWAY, DEFAULT_METHOD, DIDDomainEdgeRouter, type DIDMethod, DIDNameResolver, type DIDNameResolverOptions, type DIDServiceEndpoint, type DIDType, type DIDTypeArg, type DIDTypeShortcut, type DIDTypeStr, DID_ENDPOINT_DOMAIN_TAG, DID_PREFIX, DID_TYPE_ARCBLOCK, DID_TYPE_ETHEREUM, DID_TYPE_PASSKEY, DNS_NFT_BINDING_DOMAIN_TAG, type DidEndpointRecord, type DidTlsResolutionTier, type DidTlsTargetResolution, DidType, type DnsDidLabelEncoding, type DomainNftAssetSnapshot, type DomainNftBindingProof, InMemoryNameRegistry, KEY_ROTATION_DOMAIN_TAG, type KeyRotationEvent, MAX_CUSTOM_DOMAINS_PER_DID, MAX_ROTATION_CHAIN_LENGTH, type NameHierarchy, type NameRegistry, PRE_ROTATION_DOMAIN_TAG, type ParsedDID, type RequiredDIDType, type ResolveDidTlsTargetOptions, type ResolveRoute, type ResolveTraceResult, SUBACCOUNT_DOMAIN_TAG, type SynthesizeDidDocumentOptions, type ThreeTierResolutionResult, type W3CDIDDocument, type W3CDIDVerificationMethod, createAccountMigratePreRotationData, createDomainNftBindingProof, createKeyRotationEvent, createPreRotationCommitment, decodeDidFromDnsLabels, deriveSubAccountAddress, deriveSubAccountSeed, encodeDidEndpointDigest, encodeDidForDnsLabels, encodeLengthPrefixedTuple, expandShortForm, extractAccountPreRotationData, extractDidFromDomainHost, extractIdentifier, extractMethod, formatDid, fromDnsDidLabel, fromHash, fromPublicKey, fromPublicKeyHash, fromSecretKey, fromTypeInfo, getEntityId, getResolveRoute, isAliasMethod, isCryptoMethod, isEthereumDid, isEthereumType, isFromPublicKey, isFromSubAccount, isGlobalName, isKnownDid, isKnownMethod, isLocalName, isSameEntity, isValid, isValidPreRotationCommitment, isValidStrictDnsHostname, normalizeName, normalizePreRotationCommitment, normalizePublicKeyHex, parse, parseNameHierarchy, synthesizeDidDocument, toAddress, toChecksumAddress, toDid, toDidDomainHost, toDidWellKnownUrl, toDnsDidLabel, toShortForm, toStrictHex, toTypeInfo, toTypeInfoStr, types, verifyAccountMigrationChainWithKel, verifyDomainNftBindingProof, verifyKeyRotationChain, verifyPreRotationCommitment, verifySingleKeyRotationEvent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Javascript lib to work with ArcBlock DID",
|
|
6
6
|
"keywords": [
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"url": "https://github.com/ArcBlock/blockchain/issues"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@ocap/mcrypto": "1.32.
|
|
73
|
-
"@ocap/util": "1.32.
|
|
72
|
+
"@ocap/mcrypto": "1.32.3",
|
|
73
|
+
"@ocap/util": "1.32.3",
|
|
74
74
|
"debug": "^4.4.3"
|
|
75
75
|
}
|
|
76
76
|
}
|