@sendity/client 0.1.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.
@@ -0,0 +1,101 @@
1
+ import Pusher from 'pusher-js';
2
+ declare global {
3
+ interface Window {
4
+ Pusher: typeof Pusher;
5
+ }
6
+ }
7
+ export type TransportMode = 'auto' | 'push' | 'polling';
8
+ type StoredAuthRequest = {
9
+ id: string;
10
+ clientSecret: string;
11
+ };
12
+ export declare const HOSTED_SERVER_URL = "https://sendity.io/api";
13
+ export declare const HOSTED_VERIFY_URLS: string[];
14
+ export declare const AUTH_REQUEST_TTL_MS: number;
15
+ export declare const FOOTER_WAIT_DELAY_MS = 15000;
16
+ export declare const DEFAULT_AUTHENTICATED_EVENT_DELAY_MS = 2000;
17
+ export declare function getStorageKey(serverUrl: string, publicKey: string): string;
18
+ export declare function getStoredAuthRequest(storage: Storage, serverUrl: string, publicKey: string, now?: number): StoredAuthRequest | null;
19
+ export declare function getStoredAuthRequestId(storage: Storage, serverUrl: string, publicKey: string, now?: number): string | null;
20
+ export declare function storeAuthRequest(storage: Storage, serverUrl: string, publicKey: string, authRequest: StoredAuthRequest, now?: number): void;
21
+ export declare function clearStoredAuthRequest(storage: Storage, serverUrl: string, publicKey: string): void;
22
+ export declare function filterAllowedVerifyUrls(urls: string[], baseUrl?: string): string[];
23
+ export declare function shouldStartPollingAfterRealtimeSetup(transport: TransportMode, hasBroadcastingMetadata: boolean, pushSubscribed: boolean): {
24
+ start: boolean;
25
+ delayMs: number;
26
+ };
27
+ export declare class Sendity extends HTMLElement {
28
+ private pollTimer;
29
+ private fallbackPollTimer;
30
+ private authenticatedEventTimer;
31
+ private codeContainerEl;
32
+ private codeEl;
33
+ private promptEl;
34
+ private successEl;
35
+ private spinnerEl;
36
+ private verifiersEl;
37
+ private footerEl;
38
+ private footerBrandEl;
39
+ private footerStatusEl;
40
+ private footerMessageEl;
41
+ private footerObserver;
42
+ private footerWaitTimer;
43
+ private currentConfig;
44
+ private destroyed;
45
+ private lastCode;
46
+ private echo;
47
+ private activeAuthRequestId?;
48
+ private activeAuthRequestSecret?;
49
+ private activeAuthRequestExpiresAt?;
50
+ private authenticated;
51
+ private static tailwindCssText;
52
+ private static tailwindLoading;
53
+ static get observedAttributes(): string[];
54
+ constructor();
55
+ connectedCallback(): void;
56
+ disconnectedCallback(): void;
57
+ attributeChangedCallback(): void;
58
+ private start;
59
+ private stop;
60
+ private injectTailwind;
61
+ private configureFooter;
62
+ private isFooterHidden;
63
+ private observeFooterVisibility;
64
+ private scheduleFooterWaitingState;
65
+ private showFooterWaitingState;
66
+ private handleInitialError;
67
+ private resolveConfig;
68
+ private parseAuthenticatedEventDelayMs;
69
+ private step;
70
+ private configureRealtime;
71
+ private subscribeToBroadcasting;
72
+ private startPolling;
73
+ private handleAuthenticated;
74
+ private stopAuthTransports;
75
+ private dispatchPublicEvent;
76
+ private toPublicAuthenticatedDetail;
77
+ private primaryChannel;
78
+ private authRequestStatusUrl;
79
+ private authRequestStatusInit;
80
+ private extractClientSecret;
81
+ private updateActiveAuthRequestExpiry;
82
+ private waitingFooterMessage;
83
+ private formatExpiryTime;
84
+ private localeForLang;
85
+ private updateCodeValidityDuration;
86
+ private fetchAuthorizationAfterAuthenticatedSignal;
87
+ private updateCode;
88
+ private renderError;
89
+ private showLoading;
90
+ private showCodeState;
91
+ private showSuccess;
92
+ private escapeHtml;
93
+ private renderVerifiers;
94
+ private iconForUrl;
95
+ private labelForUrl;
96
+ private buildLink;
97
+ private applyTemplate;
98
+ private toQuery;
99
+ private joinUrl;
100
+ }
101
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type SendityI18n } from './sendity.en';
2
+ export type Lang = 'en' | 'de' | 'fr';
3
+ export declare function getI18n(lang: Lang): SendityI18n;
@@ -0,0 +1,3 @@
1
+ import type { SendityI18n } from './sendity.en';
2
+ declare const de: SendityI18n;
3
+ export default de;
@@ -0,0 +1,20 @@
1
+ export type SendityI18n = {
2
+ labels: {
3
+ email: string;
4
+ whatsapp: string;
5
+ };
6
+ ui: {
7
+ sendCodePrompt: string;
8
+ successGreeting: string;
9
+ by: string;
10
+ footerWaiting: string;
11
+ footerWaitingUntil: string;
12
+ };
13
+ templates: {
14
+ emailSubject: string;
15
+ emailBody: string;
16
+ whatsappText: string;
17
+ };
18
+ };
19
+ declare const en: SendityI18n;
20
+ export default en;
@@ -0,0 +1,3 @@
1
+ import type { SendityI18n } from './sendity.en';
2
+ declare const fr: SendityI18n;
3
+ export default fr;
@@ -0,0 +1,3 @@
1
+ import './styles/tailwind.css';
2
+ import './components/sendity';
3
+ export { Sendity } from './components/sendity';