@keyringnetwork/keyring-connect-sdk 3.2.0 → 4.1.0-alpha.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.
Files changed (68) hide show
  1. package/dist/core/VerificationSession.d.ts +62 -0
  2. package/dist/core/VerificationSession.js +404 -0
  3. package/dist/core/errors.d.ts +49 -0
  4. package/dist/core/errors.js +81 -0
  5. package/dist/core/htppClient.d.ts +17 -0
  6. package/dist/core/htppClient.js +160 -0
  7. package/dist/{main.d.ts → core/keyringConnectExtension.d.ts} +6 -4
  8. package/dist/{main.js → core/keyringConnectExtension.js} +33 -16
  9. package/dist/core/websocketClient.d.ts +23 -0
  10. package/dist/core/websocketClient.js +220 -0
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js +3 -3
  13. package/dist/types/api.d.ts +24 -0
  14. package/dist/types/api.js +2 -0
  15. package/dist/types/core.d.ts +78 -0
  16. package/dist/types/core.js +2 -0
  17. package/dist/{types.d.ts → types/extension.d.ts} +2 -49
  18. package/dist/types/index.d.ts +4 -0
  19. package/dist/types/index.js +20 -0
  20. package/dist/types/websocket.d.ts +68 -0
  21. package/dist/types/websocket.js +3 -0
  22. package/dist/ui/UIManager.d.ts +52 -0
  23. package/dist/ui/UIManager.js +257 -0
  24. package/dist/ui/components/keyring-button.d.ts +12 -0
  25. package/dist/ui/components/keyring-button.js +140 -0
  26. package/dist/ui/components/keyring-text.d.ts +12 -0
  27. package/dist/ui/components/keyring-text.js +169 -0
  28. package/dist/ui/composites/keyring-complete-modal.d.ts +19 -0
  29. package/dist/ui/composites/keyring-complete-modal.js +200 -0
  30. package/dist/ui/composites/keyring-mobile-modal.d.ts +25 -0
  31. package/dist/ui/composites/keyring-mobile-modal.js +308 -0
  32. package/dist/ui/composites/keyring-qr-modal.d.ts +32 -0
  33. package/dist/ui/composites/keyring-qr-modal.js +464 -0
  34. package/dist/ui/composites/keyring-selection-modal.d.ts +25 -0
  35. package/dist/ui/composites/keyring-selection-modal.js +342 -0
  36. package/dist/ui/composites/keyring-terminated-modal.d.ts +14 -0
  37. package/dist/ui/composites/keyring-terminated-modal.js +121 -0
  38. package/dist/ui/icons/apple-icon.d.ts +4 -0
  39. package/dist/ui/icons/apple-icon.js +47 -0
  40. package/dist/ui/icons/check-circle.d.ts +4 -0
  41. package/dist/ui/icons/check-circle.js +35 -0
  42. package/dist/ui/icons/checkmark.d.ts +4 -0
  43. package/dist/ui/icons/checkmark.js +37 -0
  44. package/dist/ui/icons/close-circle.d.ts +4 -0
  45. package/dist/ui/icons/close-circle.js +35 -0
  46. package/dist/ui/icons/error-circle.d.ts +4 -0
  47. package/dist/ui/icons/error-circle.js +48 -0
  48. package/dist/ui/icons/extension-grid.d.ts +4 -0
  49. package/dist/ui/icons/extension-grid.js +79 -0
  50. package/dist/ui/icons/google-icon.d.ts +4 -0
  51. package/dist/ui/icons/google-icon.js +55 -0
  52. package/dist/ui/icons/gradient-donut.d.ts +8 -0
  53. package/dist/ui/icons/gradient-donut.js +85 -0
  54. package/dist/ui/icons/keyring.d.ts +4 -0
  55. package/dist/ui/icons/keyring.js +71 -0
  56. package/dist/ui/icons/mobile-grid.d.ts +4 -0
  57. package/dist/ui/icons/mobile-grid.js +68 -0
  58. package/dist/ui/icons/success.d.ts +4 -0
  59. package/dist/ui/icons/success.js +54 -0
  60. package/dist/utils/environment.d.ts +34 -0
  61. package/dist/utils/environment.js +67 -0
  62. package/dist/utils/logger.d.ts +7 -0
  63. package/dist/utils/logger.js +40 -0
  64. package/dist/utils/platformUtils.d.ts +24 -0
  65. package/dist/utils/platformUtils.js +64 -0
  66. package/package.json +29 -14
  67. package/readme.md +57 -105
  68. /package/dist/{types.js → types/extension.js} +0 -0
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.KeyringMobileModal = void 0;
10
+ const lit_1 = require("lit");
11
+ const decorators_js_1 = require("lit/decorators.js");
12
+ require("../components/keyring-button");
13
+ require("../components/keyring-text");
14
+ require("../icons/checkmark");
15
+ require("../icons/gradient-donut");
16
+ require("../icons/keyring");
17
+ let KeyringMobileModal = class KeyringMobileModal extends lit_1.LitElement {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.qrData = "";
21
+ this.expiresAt = 0;
22
+ this.status = "pending";
23
+ this.statusMessage = "Waiting for mobile app...";
24
+ this.timeLeft = "";
25
+ }
26
+ connectedCallback() {
27
+ super.connectedCallback();
28
+ this.startCountdown();
29
+ this.trapFocus();
30
+ }
31
+ disconnectedCallback() {
32
+ super.disconnectedCallback();
33
+ if (this.countdownInterval) {
34
+ clearInterval(this.countdownInterval);
35
+ }
36
+ }
37
+ render() {
38
+ return (0, lit_1.html) `
39
+ <div class="modal" @click=${this.stopPropagation}>
40
+ <div class="header">
41
+ <keyring-text variant="text-2xl" weight="medium" align="center"
42
+ >Continue with mobile app</keyring-text
43
+ >
44
+ <button class="close-btn" @click=${this.handleCancel} aria-label="Close">
45
+ <svg
46
+ xmlns="http://www.w3.org/2000/svg"
47
+ width="24"
48
+ height="24"
49
+ viewBox="0 0 24 24"
50
+ fill="none"
51
+ >
52
+ <path
53
+ d="M16.0391 6.54694C16.4296 6.15641 17.0626 6.15641 17.4531 6.54694C17.8436 6.93747 17.8436 7.5705 17.4531 7.961L13.4141 12.0001L17.4531 16.0391C17.8436 16.4297 17.8436 17.0627 17.4531 17.4532C17.0626 17.8437 16.4296 17.8436 16.0391 17.4532L12 13.4141L7.96094 17.4532C7.57044 17.8437 6.93741 17.8436 6.54688 17.4532C6.15635 17.0627 6.15635 16.4296 6.54688 16.0391L10.5859 12.0001L6.54688 7.961C6.15635 7.57047 6.15635 6.93746 6.54688 6.54694C6.9374 6.15641 7.57041 6.15641 7.96094 6.54694L12 10.586L16.0391 6.54694Z"
54
+ fill="#75849A"
55
+ />
56
+ </svg>
57
+ </button>
58
+ </div>
59
+
60
+ <div class="content">
61
+ <a href="${this.qrData}" target="_blank" class="launch-link">
62
+ <keyring-button class="done-button">Launch Keyring App</keyring-button>
63
+ </a>
64
+ </div>
65
+
66
+ <div class="footer">
67
+ <div class="footer-content">
68
+ <div class="footer-branding">
69
+ <keyring-text variant="text-sm" color="secondary"
70
+ >Verification provided by</keyring-text
71
+ >
72
+ <keyring-icon></keyring-icon>
73
+ </div>
74
+ <div class="footer-links">
75
+ <a href="https://www.keyring.network/terms" target="_blank" class="link">
76
+ <keyring-text variant="text-sm" color="secondary"
77
+ >Keyring Terms and Conditions</keyring-text
78
+ >
79
+ </a>
80
+ <a href="https://docs.keyring.network/docs" target="_blank" class="link">
81
+ <keyring-text variant="text-sm" color="secondary">Keyring Docs</keyring-text>
82
+ </a>
83
+ </div>
84
+ </div>
85
+
86
+ <div class="status-container ${this.status === "connected" ? "connected" : ""}">
87
+ <div class="status-item">
88
+ ${this.getStatusIcon()}
89
+ <keyring-text variant="text-sm">${this.statusMessage}</keyring-text>
90
+ </div>
91
+ ${this.timeLeft !== "00:00"
92
+ ? (0, lit_1.html) `
93
+ <keyring-text variant="text-xs" color="secondary">
94
+ Expires: <span>${this.timeLeft}</span>
95
+ </keyring-text>
96
+ `
97
+ : (0, lit_1.html) ``}
98
+ </div>
99
+ </div>
100
+ </div>
101
+ `;
102
+ }
103
+ updateStatus(message, status) {
104
+ this.statusMessage = message;
105
+ this.status = status;
106
+ }
107
+ // Event handlers
108
+ handleCancel() {
109
+ this.dispatchEvent(new CustomEvent("cancel", { bubbles: true, composed: true }));
110
+ }
111
+ stopPropagation(e) {
112
+ e.stopPropagation();
113
+ }
114
+ trapFocus() {
115
+ var _a;
116
+ // Simple focus trap implementation
117
+ const focusableElements = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('button:not([style*="display: none"]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
118
+ if (focusableElements && focusableElements.length > 0) {
119
+ focusableElements[0].focus();
120
+ }
121
+ }
122
+ startCountdown() {
123
+ if (this.countdownInterval) {
124
+ clearInterval(this.countdownInterval);
125
+ }
126
+ const updateCountdown = () => {
127
+ const now = Date.now();
128
+ const timeLeft = this.expiresAt - now;
129
+ if (timeLeft <= 0) {
130
+ this.timeLeft = "00:00";
131
+ this.updateStatus("Session expired", "expired");
132
+ if (this.countdownInterval)
133
+ clearInterval(this.countdownInterval);
134
+ return;
135
+ }
136
+ const minutes = Math.floor(timeLeft / 60000);
137
+ const seconds = Math.floor((timeLeft % 60000) / 1000);
138
+ this.timeLeft = `${minutes}:${seconds.toString().padStart(2, "0")}`;
139
+ };
140
+ updateCountdown();
141
+ this.countdownInterval = window.setInterval(updateCountdown, 1000);
142
+ }
143
+ getStatusIcon() {
144
+ switch (this.status) {
145
+ case "pending":
146
+ case "processing":
147
+ return (0, lit_1.html) `<gradient-donut-icon spinning></gradient-donut-icon>`;
148
+ case "connected":
149
+ return (0, lit_1.html) `<checkmark-icon></checkmark-icon>`;
150
+ default:
151
+ return (0, lit_1.html) `<gradient-donut-icon startColour="#75849A"></gradient-donut-icon>`;
152
+ }
153
+ }
154
+ };
155
+ exports.KeyringMobileModal = KeyringMobileModal;
156
+ KeyringMobileModal.styles = (0, lit_1.css) `
157
+ :host {
158
+ position: fixed;
159
+ top: 0;
160
+ left: 0;
161
+ right: 0;
162
+ bottom: 0;
163
+ background-color: rgba(15, 40, 48, 0.45);
164
+ display: flex;
165
+ align-items: center;
166
+ justify-content: center;
167
+ z-index: 10000;
168
+ font-family: Inter, "Segoe UI", Roboto, sans-serif;
169
+ }
170
+
171
+ .modal {
172
+ background: white;
173
+ border-radius: 20px;
174
+ display: flex;
175
+ gap: 24px;
176
+ padding: 40px 16px 24px;
177
+ flex-direction: column;
178
+ align-items: center;
179
+ max-width: 350px;
180
+ width: 100%;
181
+ max-height: 90vh;
182
+ overflow-y: auto;
183
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
184
+ position: relative;
185
+ }
186
+
187
+ .header {
188
+ display: flex;
189
+ justify-content: center;
190
+ align-items: center;
191
+ width: 100%;
192
+ }
193
+
194
+ .close-btn {
195
+ background-color: transparent;
196
+ border: none;
197
+ cursor: pointer;
198
+ padding: 4px;
199
+ border-radius: 8px;
200
+ transition: all 300ms ease-in-out;
201
+ position: absolute;
202
+ top: 8px;
203
+ right: 8px;
204
+ }
205
+
206
+ .close-btn:hover {
207
+ background-color: #75849a1a;
208
+ }
209
+
210
+ .content {
211
+ width: 100%;
212
+ display: flex;
213
+ justify-content: center;
214
+ }
215
+
216
+ .done-button {
217
+ width: 100%;
218
+ max-width: 180px;
219
+ margin: 0 auto;
220
+ }
221
+
222
+ .launch-link {
223
+ text-decoration: none;
224
+ color: inherit;
225
+ cursor: pointer;
226
+ width: 100%;
227
+ text-align: center;
228
+ }
229
+
230
+ .status-container {
231
+ margin: 24px -16px -24px;
232
+ padding: 8px;
233
+ border-top: 1px solid #e3e7ee;
234
+ background-color: #f3f5fa;
235
+ display: flex;
236
+ flex-direction: column;
237
+ justify-content: center;
238
+ align-items: center;
239
+ }
240
+
241
+ .status-container.connected {
242
+ background-color: #f2fcf7;
243
+ border-color: #e3e7ee;
244
+ }
245
+
246
+ .status-item {
247
+ display: flex;
248
+ align-items: center;
249
+ justify-content: center;
250
+ gap: 12px;
251
+ }
252
+
253
+ .footer {
254
+ width: 100%;
255
+ border-top: 1px solid rgba(15, 40, 48, 0.12);
256
+ }
257
+
258
+ .footer-content {
259
+ display: flex;
260
+ flex-direction: column;
261
+ gap: 12px;
262
+ margin-top: 24px;
263
+ }
264
+
265
+ .footer-branding {
266
+ display: flex;
267
+ gap: 12px;
268
+ align-items: center;
269
+ justify-content: center;
270
+ }
271
+
272
+ .footer-links {
273
+ width: 100%;
274
+ display: flex;
275
+ gap: 24px;
276
+ align-items: center;
277
+ justify-content: center;
278
+ }
279
+
280
+ .footer-links a {
281
+ text-decoration: none;
282
+ color: inherit;
283
+ cursor: pointer;
284
+ }
285
+
286
+ .footer-links a:hover {
287
+ text-decoration: underline;
288
+ color: #75849a;
289
+ }
290
+ `;
291
+ __decorate([
292
+ (0, decorators_js_1.property)({ attribute: "qr-data" })
293
+ ], KeyringMobileModal.prototype, "qrData", void 0);
294
+ __decorate([
295
+ (0, decorators_js_1.property)({ attribute: "expires-at", type: Number })
296
+ ], KeyringMobileModal.prototype, "expiresAt", void 0);
297
+ __decorate([
298
+ (0, decorators_js_1.state)()
299
+ ], KeyringMobileModal.prototype, "status", void 0);
300
+ __decorate([
301
+ (0, decorators_js_1.state)()
302
+ ], KeyringMobileModal.prototype, "statusMessage", void 0);
303
+ __decorate([
304
+ (0, decorators_js_1.state)()
305
+ ], KeyringMobileModal.prototype, "timeLeft", void 0);
306
+ exports.KeyringMobileModal = KeyringMobileModal = __decorate([
307
+ (0, decorators_js_1.customElement)("keyring-mobile-modal")
308
+ ], KeyringMobileModal);
@@ -0,0 +1,32 @@
1
+ import { LitElement } from "lit";
2
+ import "../components/keyring-button";
3
+ import "../components/keyring-text";
4
+ import "../icons/apple-icon";
5
+ import "../icons/checkmark";
6
+ import "../icons/google-icon";
7
+ import "../icons/gradient-donut";
8
+ export type ModalStatus = "pending" | "connected" | "processing" | "completed" | "failed" | "expired";
9
+ export declare class KeyringQRModal extends LitElement {
10
+ sessionId: string;
11
+ expiresAt: number;
12
+ qrData: string;
13
+ qrCodeError: boolean;
14
+ private status;
15
+ private statusMessage;
16
+ private timeLeft;
17
+ private linkCopied;
18
+ private countdownInterval?;
19
+ static styles: import("lit").CSSResult;
20
+ connectedCallback(): void;
21
+ disconnectedCallback(): void;
22
+ render(): import("lit").TemplateResult<1>;
23
+ updateStatus(message: string, status: ModalStatus): void;
24
+ private handleClose;
25
+ private handleCancel;
26
+ private handleBack;
27
+ private stopPropagation;
28
+ private startCountdown;
29
+ private trapFocus;
30
+ private getStatusIcon;
31
+ private onCopy;
32
+ }