@sirosfoundation/wcc-types 0.1.0-beta.0
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/LICENSE +25 -0
- package/README.md +15 -0
- package/dist/index.d.mts +196 -0
- package/dist/index.mjs +1 -0
- package/package.json +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, SIROS Foundation
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
20
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
23
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
24
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
25
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Wallet Companion client types.
|
|
2
|
+
|
|
3
|
+
Types for the Wallet Companion client API.
|
|
4
|
+
|
|
5
|
+
## Support
|
|
6
|
+
|
|
7
|
+
- Issues: [GitHub Issues](https://github.com/sirosfoundation/wallet-companion/issues)
|
|
8
|
+
- Discussions: [GitHub Discussions](https://github.com/sirosfoundation/wallet-companion/discussions)
|
|
9
|
+
- Documentation: see links above
|
|
10
|
+
|
|
11
|
+
## License
|
|
12
|
+
|
|
13
|
+
BSD 2-Clause License - see [LICENSE](LICENSE) file for details.
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2026 - present, SIROS Foundation
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
//#region src/WalletCompanionInterface.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Public API for the Wallet Companion browser extension.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* if (window.WalletCompanion?.isInstalled) {
|
|
8
|
+
* await window.WalletCompanion.registerWallet({
|
|
9
|
+
* name: 'My Wallet',
|
|
10
|
+
* url: 'https://wallet.example.com',
|
|
11
|
+
* protocols: ['openid4vp'],
|
|
12
|
+
* });
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
interface WalletCompanionInterface {
|
|
17
|
+
/**
|
|
18
|
+
* Semantic version of the extension (e.g. `"1.2.3"`).
|
|
19
|
+
*/
|
|
20
|
+
readonly version: string;
|
|
21
|
+
/**
|
|
22
|
+
* Always `true` when the extension is active.
|
|
23
|
+
*
|
|
24
|
+
* Since `window.WalletCompanion` is undefined when the extension is not installed,
|
|
25
|
+
* use optional chaining: `window.WalletCompanion?.isInstalled`
|
|
26
|
+
*/
|
|
27
|
+
readonly isInstalled: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Protocol identifiers supported by at least one registered wallet.
|
|
30
|
+
*
|
|
31
|
+
* Use this to check if any wallet can handle a specific protocol before initiating a flow.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* if (window.WalletCompanion?.supportedProtocols.includes('openid4vp')) {
|
|
36
|
+
* // At least one wallet supports OpenID4VP
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
readonly supportedProtocols: readonly string[];
|
|
41
|
+
/**
|
|
42
|
+
* Register a wallet with the extension.
|
|
43
|
+
*
|
|
44
|
+
* Idempotent: if the URL is already registered, returns the existing wallet.
|
|
45
|
+
*
|
|
46
|
+
* @throws {Error} If validation fails or registration times out (5s)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const { wallet, alreadyRegistered } = await window.WalletCompanion.registerWallet({
|
|
51
|
+
* name: 'My Wallet',
|
|
52
|
+
* url: 'https://wallet.example.com',
|
|
53
|
+
* protocols: ['openid4vp'],
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
registerWallet(walletInfo: WalletRegistrationInput): Promise<WalletRegistrationResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Check if a wallet URL is already registered.
|
|
60
|
+
*
|
|
61
|
+
* Use this to avoid prompting users to register a wallet they've already added.
|
|
62
|
+
*
|
|
63
|
+
* @throws {Error} If check times out (5s)
|
|
64
|
+
*/
|
|
65
|
+
isWalletRegistered(url: string): Promise<boolean>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Input for {@link WalletCompanionInterface.registerWallet}.
|
|
69
|
+
*/
|
|
70
|
+
type WalletRegistrationInput = {
|
|
71
|
+
/**
|
|
72
|
+
* Display name shown in the wallet selector UI.
|
|
73
|
+
*/
|
|
74
|
+
name: string;
|
|
75
|
+
/**
|
|
76
|
+
* Base URL where the wallet receives requests (e.g. `https://wallet.example.com`).
|
|
77
|
+
* Must use `http:` or `https:` scheme.
|
|
78
|
+
*/
|
|
79
|
+
url: string;
|
|
80
|
+
/**
|
|
81
|
+
* URL to the wallet's icon. Fetched and converted to a data-URI during registration.
|
|
82
|
+
* Recommended: square image, at least 64x64px.
|
|
83
|
+
*/
|
|
84
|
+
icon?: string | null;
|
|
85
|
+
/**
|
|
86
|
+
* Short tagline shown below the wallet name in the selector UI.
|
|
87
|
+
*/
|
|
88
|
+
description?: string | null;
|
|
89
|
+
/**
|
|
90
|
+
* Brand color used for UI accents. Must be a 6-digit hex code (e.g. `#FF0000`).
|
|
91
|
+
*/
|
|
92
|
+
color?: string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Protocol identifiers this wallet supports (e.g. `['openid4vp']`).
|
|
95
|
+
* Only wallets matching the requested protocol are shown in the selector.
|
|
96
|
+
* Format: lowercase alphanumeric with hyphens.
|
|
97
|
+
*/
|
|
98
|
+
protocols?: string[] | null;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Result from {@link WalletCompanionInterface.registerWallet}.
|
|
102
|
+
*/
|
|
103
|
+
type WalletRegistrationResult = {
|
|
104
|
+
/**
|
|
105
|
+
* `true` if the wallet is now registered (whether newly added or already existed).
|
|
106
|
+
*/
|
|
107
|
+
success: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* `true` if the wallet URL was already registered. The existing wallet is returned unchanged.
|
|
110
|
+
*/
|
|
111
|
+
alreadyRegistered: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* The registered wallet with server-generated fields populated.
|
|
114
|
+
* Only present when `success` is `true`.
|
|
115
|
+
*/
|
|
116
|
+
wallet?: Wallet;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* A wallet registered with the extension.
|
|
120
|
+
*/
|
|
121
|
+
type Wallet = {
|
|
122
|
+
/**
|
|
123
|
+
* Unique identifier generated by the extension. Use this to reference the wallet in API calls.
|
|
124
|
+
* Not derived from the URL—two wallets with different IDs may share the same URL across browser profiles.
|
|
125
|
+
*/
|
|
126
|
+
id: string;
|
|
127
|
+
/**
|
|
128
|
+
* Display name shown in the wallet selector UI.
|
|
129
|
+
*/
|
|
130
|
+
name: string;
|
|
131
|
+
/**
|
|
132
|
+
* Base URL where the wallet receives requests.
|
|
133
|
+
*/
|
|
134
|
+
url: string;
|
|
135
|
+
/**
|
|
136
|
+
* Data-URI of the wallet's icon, converted from the original URL during registration.
|
|
137
|
+
* Falls back to a generated icon if none was provided.
|
|
138
|
+
*/
|
|
139
|
+
icon: string;
|
|
140
|
+
/**
|
|
141
|
+
* Short tagline shown below the wallet name.
|
|
142
|
+
*/
|
|
143
|
+
description?: string | null;
|
|
144
|
+
/**
|
|
145
|
+
* Brand color for UI accents (6-digit hex, e.g. `#FF0000`).
|
|
146
|
+
*/
|
|
147
|
+
color?: string | null;
|
|
148
|
+
/**
|
|
149
|
+
* Protocol identifiers this wallet supports.
|
|
150
|
+
*/
|
|
151
|
+
protocols?: string[] | null;
|
|
152
|
+
/**
|
|
153
|
+
* Whether the wallet is active. Disabled wallets are hidden from the selector.
|
|
154
|
+
*/
|
|
155
|
+
enabled: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* `true` if the wallet was registered automatically (e.g. via a website's registration prompt)
|
|
158
|
+
* rather than manually by the user.
|
|
159
|
+
*/
|
|
160
|
+
autoRegistered?: boolean | null;
|
|
161
|
+
/**
|
|
162
|
+
* Origin of the page that triggered auto-registration (e.g. `https://wallet.example.com`).
|
|
163
|
+
*/
|
|
164
|
+
registeredFrom?: string | null;
|
|
165
|
+
/**
|
|
166
|
+
* ISO 8601 timestamp of when the wallet was registered.
|
|
167
|
+
*/
|
|
168
|
+
registeredAt?: string | null;
|
|
169
|
+
};
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/index.d.ts
|
|
172
|
+
declare global {
|
|
173
|
+
interface Window {
|
|
174
|
+
/**
|
|
175
|
+
* Client API for the Wallet Companion browser extension.
|
|
176
|
+
*
|
|
177
|
+
* Undefined when the extension is not installed. Use optional chaining to check availability:
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* if (window.WalletCompanion?.isInstalled) {
|
|
182
|
+
* await window.WalletCompanion.registerWallet({
|
|
183
|
+
* name: 'My Wallet',
|
|
184
|
+
* url: 'https://wallet.example.com',
|
|
185
|
+
* protocols: ['openid4vp'],
|
|
186
|
+
* });
|
|
187
|
+
* }
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @see https://github.com/sirosfoundation/wallet-companion
|
|
191
|
+
*/
|
|
192
|
+
WalletCompanion?: WalletCompanionInterface;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
export { Wallet, WalletCompanionInterface, WalletRegistrationInput, WalletRegistrationResult };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sirosfoundation/wcc-types",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "Wallet Companion client types",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
|
+
"import": "./dist/index.mjs"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/"
|
|
14
|
+
],
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"tsdown": "^0.22.2"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsdown"
|
|
20
|
+
}
|
|
21
|
+
}
|