@partylayer/core 0.2.7 → 0.3.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/index.d.mts +135 -1
- package/dist/index.d.ts +135 -1
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
- package/LICENSE +0 -21
package/dist/index.d.mts
CHANGED
|
@@ -57,6 +57,62 @@ interface AdapterMetadata {
|
|
|
57
57
|
/** Version range (semver) */
|
|
58
58
|
versionRange: string;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Provider matcher: a single rule used by `ProviderDetection.matchers`.
|
|
62
|
+
*
|
|
63
|
+
* Three match modes are defined; OR-combined inside a `ProviderDetection`.
|
|
64
|
+
* Exact and prefix work on string fields directly; domain interprets the
|
|
65
|
+
* field as a URL and tests its hostname against the registrable domain
|
|
66
|
+
* (with subdomain support).
|
|
67
|
+
*/
|
|
68
|
+
type ProviderMatcher = {
|
|
69
|
+
field: 'kernel.url' | 'kernel.userUrl';
|
|
70
|
+
match: 'domain';
|
|
71
|
+
/** Hostname or registrable domain. Subdomains are accepted. */
|
|
72
|
+
value: string;
|
|
73
|
+
} | {
|
|
74
|
+
field: 'kernel.id' | 'kernel.url' | 'kernel.userUrl' | 'kernel.clientType' | 'provider.id';
|
|
75
|
+
match: 'exact';
|
|
76
|
+
/** One or more exact values; ANY match returns true. */
|
|
77
|
+
values: string[];
|
|
78
|
+
} | {
|
|
79
|
+
field: 'kernel.id' | 'kernel.url' | 'kernel.userUrl';
|
|
80
|
+
match: 'prefix';
|
|
81
|
+
value: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Standards-first runtime detection of a CIP-0103 wallet.
|
|
85
|
+
*
|
|
86
|
+
* The registry stores these rules so that any current or future wallet
|
|
87
|
+
* implementing `window.canton` can be identified without code changes —
|
|
88
|
+
* a registry JSON update is enough.
|
|
89
|
+
*/
|
|
90
|
+
interface ProviderDetection {
|
|
91
|
+
/** Transport mechanism. Currently only 'window.canton' is supported. */
|
|
92
|
+
transport: 'window.canton';
|
|
93
|
+
/** OR-list of matchers. Provider matches if ANY matcher returns true. */
|
|
94
|
+
matchers: ProviderMatcher[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Canonical CIP-0103 support marker.
|
|
98
|
+
*
|
|
99
|
+
* When `native: true`, the wallet is treated as a first-class CIP-0103
|
|
100
|
+
* provider in the picker — it always appears in the "CIP-0103 NATIVE"
|
|
101
|
+
* section regardless of install state, with a per-wallet readiness
|
|
102
|
+
* indicator that reflects whether the wallet's `providerDetection` rules
|
|
103
|
+
* matched the currently-injected `window.canton` provider.
|
|
104
|
+
*
|
|
105
|
+
* The field is optional; wallets that don't claim CIP-0103 support omit
|
|
106
|
+
* it and continue to appear in the "AVAILABLE" section as before.
|
|
107
|
+
*/
|
|
108
|
+
interface Cip0103Support {
|
|
109
|
+
/** True if this wallet has confirmed CIP-0103 dApp API support. */
|
|
110
|
+
native: boolean;
|
|
111
|
+
/** Public evidence link (npm package, blog post, official statement). */
|
|
112
|
+
evidence?: string;
|
|
113
|
+
/** ISO date when CIP-0103 support was confirmed (informational). */
|
|
114
|
+
since?: string;
|
|
115
|
+
}
|
|
60
116
|
/**
|
|
61
117
|
* Wallet information from registry
|
|
62
118
|
*/
|
|
@@ -91,7 +147,29 @@ interface WalletInfo {
|
|
|
91
147
|
channel: 'stable' | 'beta';
|
|
92
148
|
/** Additional metadata (e.g., originAllowlist) */
|
|
93
149
|
metadata?: Record<string, string>;
|
|
150
|
+
/**
|
|
151
|
+
* Optional CIP-0103 runtime detection rules. When present, the picker can
|
|
152
|
+
* decide whether this wallet is the currently-injected `window.canton`
|
|
153
|
+
* provider and route it into the "CIP-0103 Native" section without any
|
|
154
|
+
* hardcoded wallet IDs. Wallets that aren't CIP-0103-injected (e.g. Bron,
|
|
155
|
+
* Cantor8 deeplink) leave this unset.
|
|
156
|
+
*/
|
|
157
|
+
providerDetection?: ProviderDetection;
|
|
158
|
+
/**
|
|
159
|
+
* Canonical CIP-0103 support marker. When set with `native: true`, the
|
|
160
|
+
* picker always lists the wallet in the "CIP-0103 NATIVE" section
|
|
161
|
+
* regardless of install state.
|
|
162
|
+
*/
|
|
163
|
+
cip0103?: Cip0103Support;
|
|
94
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns true if the wallet has been canonically marked as CIP-0103
|
|
167
|
+
* native via its registry entry. The check is structural so it works on
|
|
168
|
+
* both raw `RegistryWalletEntry` shapes and converted `WalletInfo`.
|
|
169
|
+
*/
|
|
170
|
+
declare function isCip0103Native(entry: {
|
|
171
|
+
cip0103?: Cip0103Support;
|
|
172
|
+
}): boolean;
|
|
95
173
|
/**
|
|
96
174
|
* Session information
|
|
97
175
|
* Sessions are origin-bound and encrypted in storage
|
|
@@ -616,6 +694,62 @@ declare function isSessionExpired(session: Session): boolean;
|
|
|
616
694
|
*/
|
|
617
695
|
declare function createSession(walletId: string, partyId: string, network: string, origin: string, capabilities?: string[], expiresInMs?: number): Session;
|
|
618
696
|
|
|
697
|
+
/**
|
|
698
|
+
* Standards-first CIP-0103 wallet detection.
|
|
699
|
+
*
|
|
700
|
+
* The registry stores `providerDetection` rules per wallet entry. At
|
|
701
|
+
* runtime the picker calls `window.canton.request({method:'status'})`,
|
|
702
|
+
* receives the wallet's self-reported identity (kernel.id / kernel.url /
|
|
703
|
+
* kernel.userUrl / kernel.clientType), and asks `findMatchingWallet`
|
|
704
|
+
* which registry entry — if any — claims this provider.
|
|
705
|
+
*
|
|
706
|
+
* The architecture deliberately avoids hardcoding wallet IDs anywhere
|
|
707
|
+
* outside the registry. Adding a new CIP-0103 wallet to the ecosystem
|
|
708
|
+
* is a registry JSON update; no SDK release is required.
|
|
709
|
+
*/
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* The shape of a CIP-0103 status response that detection cares about.
|
|
713
|
+
*
|
|
714
|
+
* Mirrors what `window.canton.request({ method: 'status' })` returns —
|
|
715
|
+
* declared structurally so adapter packages can reuse this without
|
|
716
|
+
* reaching into the wallet-specific types.
|
|
717
|
+
*/
|
|
718
|
+
interface Cip0103StatusForDetection {
|
|
719
|
+
kernel?: {
|
|
720
|
+
id?: string;
|
|
721
|
+
url?: string;
|
|
722
|
+
userUrl?: string;
|
|
723
|
+
clientType?: string;
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
/** Returns true if the runtime status matches any of the detection's matchers. */
|
|
727
|
+
declare function matchesProviderDetection(status: Cip0103StatusForDetection | null | undefined, detection: ProviderDetection | undefined): boolean;
|
|
728
|
+
/**
|
|
729
|
+
* Find the first registry entry whose `providerDetection` matches the
|
|
730
|
+
* runtime status. Entries without `providerDetection` are skipped.
|
|
731
|
+
*
|
|
732
|
+
* Accepts either the raw `RegistryWalletEntry[]` shape (registry-client's
|
|
733
|
+
* native input) or the converted `WalletInfo[]` shape that flows through
|
|
734
|
+
* the SDK / React layer — the only field read is `providerDetection`,
|
|
735
|
+
* which both shapes carry post-conversion.
|
|
736
|
+
*/
|
|
737
|
+
declare function findMatchingWallet<T extends {
|
|
738
|
+
providerDetection?: ProviderDetection;
|
|
739
|
+
}>(status: Cip0103StatusForDetection | null | undefined, registry: readonly T[]): T | undefined;
|
|
740
|
+
/**
|
|
741
|
+
* Type-guard convenience for the WalletInfo shape, since the SDK exposes
|
|
742
|
+
* `WalletInfo[]` to React consumers.
|
|
743
|
+
*/
|
|
744
|
+
declare function findMatchingWalletInfo(status: Cip0103StatusForDetection | null | undefined, wallets: readonly WalletInfo[]): WalletInfo | undefined;
|
|
745
|
+
/**
|
|
746
|
+
* Best-effort display name for an unrecognised CIP-0103 provider. Reads
|
|
747
|
+
* the wallet's self-declared `kernel.userUrl` (the human-facing URL
|
|
748
|
+
* surfaced by Sigilry-style wallets) and falls back to `kernel.id` or
|
|
749
|
+
* a generic label.
|
|
750
|
+
*/
|
|
751
|
+
declare function deriveGenericWalletName(status: Cip0103StatusForDetection | null | undefined): string;
|
|
752
|
+
|
|
619
753
|
/**
|
|
620
754
|
* Transport layer types for wallet communication
|
|
621
755
|
*
|
|
@@ -1220,4 +1354,4 @@ interface Transport {
|
|
|
1220
1354
|
disconnect(): Promise<void>;
|
|
1221
1355
|
}
|
|
1222
1356
|
|
|
1223
|
-
export { type AdapterConnectResult, type AdapterContext, type AdapterDetectResult, type AdapterEventName, type AdapterMetadata, type CIP0103Account, type CIP0103AccountStatus, type CIP0103ConnectResult, type CIP0103Event, type CIP0103EventListener, type CIP0103LedgerApiRequest, type CIP0103LedgerApiResponse, type CIP0103Method, type CIP0103Network, type CIP0103Provider, type CIP0103ProviderInfo, type CIP0103ProviderRpcError, type CIP0103ProviderType, type CIP0103RequestParams, type CIP0103RequestPayload, type CIP0103SignMessageRequest, type CIP0103StatusEvent, type CIP0103TxChangedEvent, type CIP0103TxExecutedPayload, type CIP0103TxFailedPayload, type CIP0103TxPendingPayload, type CIP0103TxSignedPayload, type CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, type CapabilityKey, CapabilityNotSupportedError, type ConnectRequest, type ConnectResponse, type CryptoAdapter, DeepLinkTransport, ENABLEMENT_METRICS, ERROR_METRICS, type ErrorCode, type ErrorMappingContext, type InstallHints, InternalError, type JobStatus, type LedgerApiParams, type LedgerApiResult, type LoggerAdapter, METRICS, type MetricName, type MetricsPayload, MockTransport, type NetworkId, OriginNotAllowedError, type PartyId, PartyLayerError, type PersistedSession, PopupTransport, PostMessageTransport, REGISTRY_METRICS, type RegistryClientAdapter, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, type Session, SessionExpiredError, type SessionId, type SignMessageParams, type SignRequest, type SignResponse, type SignTransactionParams, type Signature, type SignedMessage, type SignedTransaction, type StorageAdapter, type SubmitTransactionParams, type TelemetryAdapter, TimeoutError, type TransactionHash, type TransactionStatus, type Transport, TransportError, type TransportOptions, type TransportType, type TxReceipt, type TxStatusUpdate, UserRejectedError, type WalletAdapter, type WalletId, type WalletInfo, WalletNotFoundError, WalletNotInstalledError, capabilityGuard, createMetricsPayload, createSession, errorMetricName, generateSessionId, hashForPrivacy, installGuard, isSessionExpired, mapUnknownErrorToPartyLayerError, toPartyId, toSessionId, toSignature, toTransactionHash, toWalletId, validatePayload, validateSession };
|
|
1357
|
+
export { type AdapterConnectResult, type AdapterContext, type AdapterDetectResult, type AdapterEventName, type AdapterMetadata, type CIP0103Account, type CIP0103AccountStatus, type CIP0103ConnectResult, type CIP0103Event, type CIP0103EventListener, type CIP0103LedgerApiRequest, type CIP0103LedgerApiResponse, type CIP0103Method, type CIP0103Network, type CIP0103Provider, type CIP0103ProviderInfo, type CIP0103ProviderRpcError, type CIP0103ProviderType, type CIP0103RequestParams, type CIP0103RequestPayload, type CIP0103SignMessageRequest, type CIP0103StatusEvent, type CIP0103TxChangedEvent, type CIP0103TxExecutedPayload, type CIP0103TxFailedPayload, type CIP0103TxPendingPayload, type CIP0103TxSignedPayload, type CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, type CapabilityKey, CapabilityNotSupportedError, type Cip0103StatusForDetection, type Cip0103Support, type ConnectRequest, type ConnectResponse, type CryptoAdapter, DeepLinkTransport, ENABLEMENT_METRICS, ERROR_METRICS, type ErrorCode, type ErrorMappingContext, type InstallHints, InternalError, type JobStatus, type LedgerApiParams, type LedgerApiResult, type LoggerAdapter, METRICS, type MetricName, type MetricsPayload, MockTransport, type NetworkId, OriginNotAllowedError, type PartyId, PartyLayerError, type PersistedSession, PopupTransport, PostMessageTransport, type ProviderDetection, type ProviderMatcher, REGISTRY_METRICS, type RegistryClientAdapter, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, type Session, SessionExpiredError, type SessionId, type SignMessageParams, type SignRequest, type SignResponse, type SignTransactionParams, type Signature, type SignedMessage, type SignedTransaction, type StorageAdapter, type SubmitTransactionParams, type TelemetryAdapter, TimeoutError, type TransactionHash, type TransactionStatus, type Transport, TransportError, type TransportOptions, type TransportType, type TxReceipt, type TxStatusUpdate, UserRejectedError, type WalletAdapter, type WalletId, type WalletInfo, WalletNotFoundError, WalletNotInstalledError, capabilityGuard, createMetricsPayload, createSession, deriveGenericWalletName, errorMetricName, findMatchingWallet, findMatchingWalletInfo, generateSessionId, hashForPrivacy, installGuard, isCip0103Native, isSessionExpired, mapUnknownErrorToPartyLayerError, matchesProviderDetection, toPartyId, toSessionId, toSignature, toTransactionHash, toWalletId, validatePayload, validateSession };
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,62 @@ interface AdapterMetadata {
|
|
|
57
57
|
/** Version range (semver) */
|
|
58
58
|
versionRange: string;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Provider matcher: a single rule used by `ProviderDetection.matchers`.
|
|
62
|
+
*
|
|
63
|
+
* Three match modes are defined; OR-combined inside a `ProviderDetection`.
|
|
64
|
+
* Exact and prefix work on string fields directly; domain interprets the
|
|
65
|
+
* field as a URL and tests its hostname against the registrable domain
|
|
66
|
+
* (with subdomain support).
|
|
67
|
+
*/
|
|
68
|
+
type ProviderMatcher = {
|
|
69
|
+
field: 'kernel.url' | 'kernel.userUrl';
|
|
70
|
+
match: 'domain';
|
|
71
|
+
/** Hostname or registrable domain. Subdomains are accepted. */
|
|
72
|
+
value: string;
|
|
73
|
+
} | {
|
|
74
|
+
field: 'kernel.id' | 'kernel.url' | 'kernel.userUrl' | 'kernel.clientType' | 'provider.id';
|
|
75
|
+
match: 'exact';
|
|
76
|
+
/** One or more exact values; ANY match returns true. */
|
|
77
|
+
values: string[];
|
|
78
|
+
} | {
|
|
79
|
+
field: 'kernel.id' | 'kernel.url' | 'kernel.userUrl';
|
|
80
|
+
match: 'prefix';
|
|
81
|
+
value: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Standards-first runtime detection of a CIP-0103 wallet.
|
|
85
|
+
*
|
|
86
|
+
* The registry stores these rules so that any current or future wallet
|
|
87
|
+
* implementing `window.canton` can be identified without code changes —
|
|
88
|
+
* a registry JSON update is enough.
|
|
89
|
+
*/
|
|
90
|
+
interface ProviderDetection {
|
|
91
|
+
/** Transport mechanism. Currently only 'window.canton' is supported. */
|
|
92
|
+
transport: 'window.canton';
|
|
93
|
+
/** OR-list of matchers. Provider matches if ANY matcher returns true. */
|
|
94
|
+
matchers: ProviderMatcher[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Canonical CIP-0103 support marker.
|
|
98
|
+
*
|
|
99
|
+
* When `native: true`, the wallet is treated as a first-class CIP-0103
|
|
100
|
+
* provider in the picker — it always appears in the "CIP-0103 NATIVE"
|
|
101
|
+
* section regardless of install state, with a per-wallet readiness
|
|
102
|
+
* indicator that reflects whether the wallet's `providerDetection` rules
|
|
103
|
+
* matched the currently-injected `window.canton` provider.
|
|
104
|
+
*
|
|
105
|
+
* The field is optional; wallets that don't claim CIP-0103 support omit
|
|
106
|
+
* it and continue to appear in the "AVAILABLE" section as before.
|
|
107
|
+
*/
|
|
108
|
+
interface Cip0103Support {
|
|
109
|
+
/** True if this wallet has confirmed CIP-0103 dApp API support. */
|
|
110
|
+
native: boolean;
|
|
111
|
+
/** Public evidence link (npm package, blog post, official statement). */
|
|
112
|
+
evidence?: string;
|
|
113
|
+
/** ISO date when CIP-0103 support was confirmed (informational). */
|
|
114
|
+
since?: string;
|
|
115
|
+
}
|
|
60
116
|
/**
|
|
61
117
|
* Wallet information from registry
|
|
62
118
|
*/
|
|
@@ -91,7 +147,29 @@ interface WalletInfo {
|
|
|
91
147
|
channel: 'stable' | 'beta';
|
|
92
148
|
/** Additional metadata (e.g., originAllowlist) */
|
|
93
149
|
metadata?: Record<string, string>;
|
|
150
|
+
/**
|
|
151
|
+
* Optional CIP-0103 runtime detection rules. When present, the picker can
|
|
152
|
+
* decide whether this wallet is the currently-injected `window.canton`
|
|
153
|
+
* provider and route it into the "CIP-0103 Native" section without any
|
|
154
|
+
* hardcoded wallet IDs. Wallets that aren't CIP-0103-injected (e.g. Bron,
|
|
155
|
+
* Cantor8 deeplink) leave this unset.
|
|
156
|
+
*/
|
|
157
|
+
providerDetection?: ProviderDetection;
|
|
158
|
+
/**
|
|
159
|
+
* Canonical CIP-0103 support marker. When set with `native: true`, the
|
|
160
|
+
* picker always lists the wallet in the "CIP-0103 NATIVE" section
|
|
161
|
+
* regardless of install state.
|
|
162
|
+
*/
|
|
163
|
+
cip0103?: Cip0103Support;
|
|
94
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns true if the wallet has been canonically marked as CIP-0103
|
|
167
|
+
* native via its registry entry. The check is structural so it works on
|
|
168
|
+
* both raw `RegistryWalletEntry` shapes and converted `WalletInfo`.
|
|
169
|
+
*/
|
|
170
|
+
declare function isCip0103Native(entry: {
|
|
171
|
+
cip0103?: Cip0103Support;
|
|
172
|
+
}): boolean;
|
|
95
173
|
/**
|
|
96
174
|
* Session information
|
|
97
175
|
* Sessions are origin-bound and encrypted in storage
|
|
@@ -616,6 +694,62 @@ declare function isSessionExpired(session: Session): boolean;
|
|
|
616
694
|
*/
|
|
617
695
|
declare function createSession(walletId: string, partyId: string, network: string, origin: string, capabilities?: string[], expiresInMs?: number): Session;
|
|
618
696
|
|
|
697
|
+
/**
|
|
698
|
+
* Standards-first CIP-0103 wallet detection.
|
|
699
|
+
*
|
|
700
|
+
* The registry stores `providerDetection` rules per wallet entry. At
|
|
701
|
+
* runtime the picker calls `window.canton.request({method:'status'})`,
|
|
702
|
+
* receives the wallet's self-reported identity (kernel.id / kernel.url /
|
|
703
|
+
* kernel.userUrl / kernel.clientType), and asks `findMatchingWallet`
|
|
704
|
+
* which registry entry — if any — claims this provider.
|
|
705
|
+
*
|
|
706
|
+
* The architecture deliberately avoids hardcoding wallet IDs anywhere
|
|
707
|
+
* outside the registry. Adding a new CIP-0103 wallet to the ecosystem
|
|
708
|
+
* is a registry JSON update; no SDK release is required.
|
|
709
|
+
*/
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* The shape of a CIP-0103 status response that detection cares about.
|
|
713
|
+
*
|
|
714
|
+
* Mirrors what `window.canton.request({ method: 'status' })` returns —
|
|
715
|
+
* declared structurally so adapter packages can reuse this without
|
|
716
|
+
* reaching into the wallet-specific types.
|
|
717
|
+
*/
|
|
718
|
+
interface Cip0103StatusForDetection {
|
|
719
|
+
kernel?: {
|
|
720
|
+
id?: string;
|
|
721
|
+
url?: string;
|
|
722
|
+
userUrl?: string;
|
|
723
|
+
clientType?: string;
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
/** Returns true if the runtime status matches any of the detection's matchers. */
|
|
727
|
+
declare function matchesProviderDetection(status: Cip0103StatusForDetection | null | undefined, detection: ProviderDetection | undefined): boolean;
|
|
728
|
+
/**
|
|
729
|
+
* Find the first registry entry whose `providerDetection` matches the
|
|
730
|
+
* runtime status. Entries without `providerDetection` are skipped.
|
|
731
|
+
*
|
|
732
|
+
* Accepts either the raw `RegistryWalletEntry[]` shape (registry-client's
|
|
733
|
+
* native input) or the converted `WalletInfo[]` shape that flows through
|
|
734
|
+
* the SDK / React layer — the only field read is `providerDetection`,
|
|
735
|
+
* which both shapes carry post-conversion.
|
|
736
|
+
*/
|
|
737
|
+
declare function findMatchingWallet<T extends {
|
|
738
|
+
providerDetection?: ProviderDetection;
|
|
739
|
+
}>(status: Cip0103StatusForDetection | null | undefined, registry: readonly T[]): T | undefined;
|
|
740
|
+
/**
|
|
741
|
+
* Type-guard convenience for the WalletInfo shape, since the SDK exposes
|
|
742
|
+
* `WalletInfo[]` to React consumers.
|
|
743
|
+
*/
|
|
744
|
+
declare function findMatchingWalletInfo(status: Cip0103StatusForDetection | null | undefined, wallets: readonly WalletInfo[]): WalletInfo | undefined;
|
|
745
|
+
/**
|
|
746
|
+
* Best-effort display name for an unrecognised CIP-0103 provider. Reads
|
|
747
|
+
* the wallet's self-declared `kernel.userUrl` (the human-facing URL
|
|
748
|
+
* surfaced by Sigilry-style wallets) and falls back to `kernel.id` or
|
|
749
|
+
* a generic label.
|
|
750
|
+
*/
|
|
751
|
+
declare function deriveGenericWalletName(status: Cip0103StatusForDetection | null | undefined): string;
|
|
752
|
+
|
|
619
753
|
/**
|
|
620
754
|
* Transport layer types for wallet communication
|
|
621
755
|
*
|
|
@@ -1220,4 +1354,4 @@ interface Transport {
|
|
|
1220
1354
|
disconnect(): Promise<void>;
|
|
1221
1355
|
}
|
|
1222
1356
|
|
|
1223
|
-
export { type AdapterConnectResult, type AdapterContext, type AdapterDetectResult, type AdapterEventName, type AdapterMetadata, type CIP0103Account, type CIP0103AccountStatus, type CIP0103ConnectResult, type CIP0103Event, type CIP0103EventListener, type CIP0103LedgerApiRequest, type CIP0103LedgerApiResponse, type CIP0103Method, type CIP0103Network, type CIP0103Provider, type CIP0103ProviderInfo, type CIP0103ProviderRpcError, type CIP0103ProviderType, type CIP0103RequestParams, type CIP0103RequestPayload, type CIP0103SignMessageRequest, type CIP0103StatusEvent, type CIP0103TxChangedEvent, type CIP0103TxExecutedPayload, type CIP0103TxFailedPayload, type CIP0103TxPendingPayload, type CIP0103TxSignedPayload, type CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, type CapabilityKey, CapabilityNotSupportedError, type ConnectRequest, type ConnectResponse, type CryptoAdapter, DeepLinkTransport, ENABLEMENT_METRICS, ERROR_METRICS, type ErrorCode, type ErrorMappingContext, type InstallHints, InternalError, type JobStatus, type LedgerApiParams, type LedgerApiResult, type LoggerAdapter, METRICS, type MetricName, type MetricsPayload, MockTransport, type NetworkId, OriginNotAllowedError, type PartyId, PartyLayerError, type PersistedSession, PopupTransport, PostMessageTransport, REGISTRY_METRICS, type RegistryClientAdapter, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, type Session, SessionExpiredError, type SessionId, type SignMessageParams, type SignRequest, type SignResponse, type SignTransactionParams, type Signature, type SignedMessage, type SignedTransaction, type StorageAdapter, type SubmitTransactionParams, type TelemetryAdapter, TimeoutError, type TransactionHash, type TransactionStatus, type Transport, TransportError, type TransportOptions, type TransportType, type TxReceipt, type TxStatusUpdate, UserRejectedError, type WalletAdapter, type WalletId, type WalletInfo, WalletNotFoundError, WalletNotInstalledError, capabilityGuard, createMetricsPayload, createSession, errorMetricName, generateSessionId, hashForPrivacy, installGuard, isSessionExpired, mapUnknownErrorToPartyLayerError, toPartyId, toSessionId, toSignature, toTransactionHash, toWalletId, validatePayload, validateSession };
|
|
1357
|
+
export { type AdapterConnectResult, type AdapterContext, type AdapterDetectResult, type AdapterEventName, type AdapterMetadata, type CIP0103Account, type CIP0103AccountStatus, type CIP0103ConnectResult, type CIP0103Event, type CIP0103EventListener, type CIP0103LedgerApiRequest, type CIP0103LedgerApiResponse, type CIP0103Method, type CIP0103Network, type CIP0103Provider, type CIP0103ProviderInfo, type CIP0103ProviderRpcError, type CIP0103ProviderType, type CIP0103RequestParams, type CIP0103RequestPayload, type CIP0103SignMessageRequest, type CIP0103StatusEvent, type CIP0103TxChangedEvent, type CIP0103TxExecutedPayload, type CIP0103TxFailedPayload, type CIP0103TxPendingPayload, type CIP0103TxSignedPayload, type CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, type CapabilityKey, CapabilityNotSupportedError, type Cip0103StatusForDetection, type Cip0103Support, type ConnectRequest, type ConnectResponse, type CryptoAdapter, DeepLinkTransport, ENABLEMENT_METRICS, ERROR_METRICS, type ErrorCode, type ErrorMappingContext, type InstallHints, InternalError, type JobStatus, type LedgerApiParams, type LedgerApiResult, type LoggerAdapter, METRICS, type MetricName, type MetricsPayload, MockTransport, type NetworkId, OriginNotAllowedError, type PartyId, PartyLayerError, type PersistedSession, PopupTransport, PostMessageTransport, type ProviderDetection, type ProviderMatcher, REGISTRY_METRICS, type RegistryClientAdapter, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, type Session, SessionExpiredError, type SessionId, type SignMessageParams, type SignRequest, type SignResponse, type SignTransactionParams, type Signature, type SignedMessage, type SignedTransaction, type StorageAdapter, type SubmitTransactionParams, type TelemetryAdapter, TimeoutError, type TransactionHash, type TransactionStatus, type Transport, TransportError, type TransportOptions, type TransportType, type TxReceipt, type TxStatusUpdate, UserRejectedError, type WalletAdapter, type WalletId, type WalletInfo, WalletNotFoundError, WalletNotInstalledError, capabilityGuard, createMetricsPayload, createSession, deriveGenericWalletName, errorMetricName, findMatchingWallet, findMatchingWalletInfo, generateSessionId, hashForPrivacy, installGuard, isCip0103Native, isSessionExpired, mapUnknownErrorToPartyLayerError, matchesProviderDetection, toPartyId, toSessionId, toSignature, toTransactionHash, toWalletId, validatePayload, validateSession };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/types.ts
|
|
4
|
+
function isCip0103Native(entry) {
|
|
5
|
+
return entry?.cip0103?.native === true;
|
|
6
|
+
}
|
|
4
7
|
function toWalletId(id) {
|
|
5
8
|
return id;
|
|
6
9
|
}
|
|
@@ -275,6 +278,74 @@ function createSession(walletId, partyId, network, origin, capabilities = [], ex
|
|
|
275
278
|
};
|
|
276
279
|
}
|
|
277
280
|
|
|
281
|
+
// src/detection.ts
|
|
282
|
+
function matchesProviderDetection(status, detection) {
|
|
283
|
+
if (!status || !detection || !detection.matchers || detection.matchers.length === 0) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
return detection.matchers.some((m) => matchesSingle(status, m));
|
|
287
|
+
}
|
|
288
|
+
function matchesSingle(status, matcher) {
|
|
289
|
+
const fieldValue = readField(status, matcher.field);
|
|
290
|
+
if (typeof fieldValue !== "string" || fieldValue.length === 0) return false;
|
|
291
|
+
switch (matcher.match) {
|
|
292
|
+
case "exact":
|
|
293
|
+
return matcher.values.includes(fieldValue);
|
|
294
|
+
case "prefix":
|
|
295
|
+
return fieldValue.startsWith(matcher.value);
|
|
296
|
+
case "domain":
|
|
297
|
+
return matchesDomain(fieldValue, matcher.value);
|
|
298
|
+
default:
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function readField(status, field) {
|
|
303
|
+
if (!status || typeof status !== "object") return void 0;
|
|
304
|
+
const dot = field.indexOf(".");
|
|
305
|
+
if (dot < 0) return void 0;
|
|
306
|
+
const root = field.slice(0, dot);
|
|
307
|
+
const key = field.slice(dot + 1);
|
|
308
|
+
const subject = status[root];
|
|
309
|
+
if (!subject || typeof subject !== "object") return void 0;
|
|
310
|
+
const value = subject[key];
|
|
311
|
+
return typeof value === "string" ? value : void 0;
|
|
312
|
+
}
|
|
313
|
+
function matchesDomain(url, domain) {
|
|
314
|
+
try {
|
|
315
|
+
const hostname = new URL(url).hostname.toLowerCase();
|
|
316
|
+
const target = domain.toLowerCase();
|
|
317
|
+
return hostname === target || hostname.endsWith("." + target);
|
|
318
|
+
} catch {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function findMatchingWallet(status, registry) {
|
|
323
|
+
if (!status) return void 0;
|
|
324
|
+
for (const entry of registry) {
|
|
325
|
+
if (matchesProviderDetection(status, entry.providerDetection)) {
|
|
326
|
+
return entry;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return void 0;
|
|
330
|
+
}
|
|
331
|
+
function findMatchingWalletInfo(status, wallets) {
|
|
332
|
+
return findMatchingWallet(status, wallets);
|
|
333
|
+
}
|
|
334
|
+
function deriveGenericWalletName(status) {
|
|
335
|
+
const userUrl = status?.kernel?.userUrl;
|
|
336
|
+
if (typeof userUrl === "string" && userUrl.length > 0) {
|
|
337
|
+
try {
|
|
338
|
+
return new URL(userUrl).hostname.replace(/^www\./, "");
|
|
339
|
+
} catch {
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const id = status?.kernel?.id;
|
|
343
|
+
if (typeof id === "string" && id.length > 0) {
|
|
344
|
+
return `CIP-0103 wallet (${id.slice(0, 8)}\u2026)`;
|
|
345
|
+
}
|
|
346
|
+
return "CIP-0103 wallet";
|
|
347
|
+
}
|
|
348
|
+
|
|
278
349
|
// src/metrics.ts
|
|
279
350
|
var ENABLEMENT_METRICS = {
|
|
280
351
|
/** Total wallet connect() calls made */
|
|
@@ -927,12 +998,17 @@ exports.WalletNotInstalledError = WalletNotInstalledError;
|
|
|
927
998
|
exports.capabilityGuard = capabilityGuard;
|
|
928
999
|
exports.createMetricsPayload = createMetricsPayload;
|
|
929
1000
|
exports.createSession = createSession;
|
|
1001
|
+
exports.deriveGenericWalletName = deriveGenericWalletName;
|
|
930
1002
|
exports.errorMetricName = errorMetricName;
|
|
1003
|
+
exports.findMatchingWallet = findMatchingWallet;
|
|
1004
|
+
exports.findMatchingWalletInfo = findMatchingWalletInfo;
|
|
931
1005
|
exports.generateSessionId = generateSessionId;
|
|
932
1006
|
exports.hashForPrivacy = hashForPrivacy;
|
|
933
1007
|
exports.installGuard = installGuard;
|
|
1008
|
+
exports.isCip0103Native = isCip0103Native;
|
|
934
1009
|
exports.isSessionExpired = isSessionExpired;
|
|
935
1010
|
exports.mapUnknownErrorToPartyLayerError = mapUnknownErrorToPartyLayerError;
|
|
1011
|
+
exports.matchesProviderDetection = matchesProviderDetection;
|
|
936
1012
|
exports.toPartyId = toPartyId;
|
|
937
1013
|
exports.toSessionId = toSessionId;
|
|
938
1014
|
exports.toSignature = toSignature;
|