@imtbl/auth 2.10.7-alpha.2 → 2.10.7-alpha.4
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/browser/index.js +391 -0
- package/dist/node/index.cjs +411 -0
- package/dist/node/index.js +33 -57
- package/dist/types/Auth.d.ts +136 -0
- package/dist/types/authManager.d.ts +3 -4
- package/dist/types/index.d.ts +4 -5
- package/dist/types/{confirmation → login}/embeddedLoginPrompt.d.ts +1 -1
- package/dist/types/overlay/{confirmationOverlay.d.ts → loginPopupOverlay.d.ts} +1 -1
- package/dist/types/types.d.ts +27 -0
- package/dist/types/utils/typedEventEmitter.d.ts +6 -0
- package/package.json +19 -13
- package/src/Auth.ts +252 -0
- package/src/authManager.ts +10 -12
- package/src/index.ts +9 -6
- package/src/{confirmation → login}/embeddedLoginPrompt.ts +6 -10
- package/src/overlay/{confirmationOverlay.ts → loginPopupOverlay.ts} +1 -1
- package/src/types.ts +30 -0
- package/src/utils/typedEventEmitter.ts +26 -0
- package/dist/browser/index.mjs +0 -397
- package/dist/node/index.mjs +0 -397
- package/dist/types/confirmation/confirmation.d.ts +0 -28
- package/dist/types/confirmation/index.d.ts +0 -3
- package/dist/types/confirmation/popup.d.ts +0 -8
- package/src/confirmation/confirmation.ts +0 -275
- package/src/confirmation/index.ts +0 -3
- package/src/confirmation/popup.ts +0 -41
- /package/dist/types/{confirmation → login}/types.d.ts +0 -0
- /package/src/{confirmation → login}/types.ts +0 -0
|
@@ -20,15 +20,11 @@ export default class EmbeddedLoginPrompt {
|
|
|
20
20
|
this.config = config;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
private getHref = (
|
|
24
|
-
|
|
23
|
+
private getHref = () => {
|
|
24
|
+
const href = `${this.config.authenticationDomain}/im-embedded-login-prompt`
|
|
25
25
|
+ `?client_id=${this.config.oidcConfiguration.clientId}`
|
|
26
26
|
+ `&rid=${getDetail(Detail.RUNTIME_ID)}`;
|
|
27
27
|
|
|
28
|
-
if (anonymousId) {
|
|
29
|
-
href += `&third_party_a_id=${anonymousId}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
28
|
return href;
|
|
33
29
|
};
|
|
34
30
|
|
|
@@ -77,10 +73,10 @@ export default class EmbeddedLoginPrompt {
|
|
|
77
73
|
document.head.appendChild(style);
|
|
78
74
|
};
|
|
79
75
|
|
|
80
|
-
private getEmbeddedLoginIFrame = (
|
|
76
|
+
private getEmbeddedLoginIFrame = () => {
|
|
81
77
|
const embeddedLoginPrompt = document.createElement('iframe');
|
|
82
78
|
embeddedLoginPrompt.id = LOGIN_PROMPT_IFRAME_ID;
|
|
83
|
-
embeddedLoginPrompt.src = this.getHref(
|
|
79
|
+
embeddedLoginPrompt.src = this.getHref();
|
|
84
80
|
embeddedLoginPrompt.style.height = '100vh';
|
|
85
81
|
embeddedLoginPrompt.style.width = '100vw';
|
|
86
82
|
embeddedLoginPrompt.style.maxHeight = `${LOGIN_PROMPT_WINDOW_HEIGHT}px`;
|
|
@@ -96,9 +92,9 @@ export default class EmbeddedLoginPrompt {
|
|
|
96
92
|
return embeddedLoginPrompt;
|
|
97
93
|
};
|
|
98
94
|
|
|
99
|
-
public displayEmbeddedLoginPrompt(
|
|
95
|
+
public displayEmbeddedLoginPrompt(): Promise<EmbeddedLoginPromptResult> {
|
|
100
96
|
return new Promise((resolve, reject) => {
|
|
101
|
-
const embeddedLoginPrompt = this.getEmbeddedLoginIFrame(
|
|
97
|
+
const embeddedLoginPrompt = this.getEmbeddedLoginIFrame();
|
|
102
98
|
const messageHandler = ({ data, origin }: MessageEvent) => {
|
|
103
99
|
if (
|
|
104
100
|
origin !== this.config.authenticationDomain
|
|
@@ -2,7 +2,7 @@ import { PopupOverlayOptions } from '../types';
|
|
|
2
2
|
import { PASSPORT_OVERLAY_CLOSE_ID, PASSPORT_OVERLAY_TRY_AGAIN_ID } from './constants';
|
|
3
3
|
import { addLink, getBlockedOverlay, getGenericOverlay } from './elements';
|
|
4
4
|
|
|
5
|
-
export default class
|
|
5
|
+
export default class LoginPopupOverlay {
|
|
6
6
|
private disableGenericPopupOverlay: boolean;
|
|
7
7
|
|
|
8
8
|
private disableBlockedPopupOverlay: boolean;
|
package/src/types.ts
CHANGED
|
@@ -126,3 +126,33 @@ export type DirectLoginOptions = {
|
|
|
126
126
|
marketingConsentStatus?: MarketingConsentStatus;
|
|
127
127
|
email?: string;
|
|
128
128
|
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Extended login options with caching and silent login support
|
|
132
|
+
*/
|
|
133
|
+
export type LoginOptions = {
|
|
134
|
+
/** If true, attempts to use cached session without user interaction */
|
|
135
|
+
useCachedSession?: boolean;
|
|
136
|
+
/** If true, attempts silent authentication (force token refresh) */
|
|
137
|
+
useSilentLogin?: boolean;
|
|
138
|
+
/** If true, uses redirect flow instead of popup flow */
|
|
139
|
+
useRedirectFlow?: boolean;
|
|
140
|
+
/** Direct login options (social provider, email, etc.) */
|
|
141
|
+
directLoginOptions?: DirectLoginOptions;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Authentication events emitted by the Auth class
|
|
146
|
+
*/
|
|
147
|
+
export enum AuthEvents {
|
|
148
|
+
LOGGED_OUT = 'loggedOut',
|
|
149
|
+
LOGGED_IN = 'loggedIn',
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Event map for typed event emitter
|
|
154
|
+
*/
|
|
155
|
+
export interface AuthEventMap extends Record<string, any> {
|
|
156
|
+
[AuthEvents.LOGGED_OUT]: [];
|
|
157
|
+
[AuthEvents.LOGGED_IN]: [User];
|
|
158
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
|
|
3
|
+
export default class TypedEventEmitter<TEvents extends Record<string, any>> {
|
|
4
|
+
private emitter = new EventEmitter();
|
|
5
|
+
|
|
6
|
+
emit<TEventName extends keyof TEvents & string>(
|
|
7
|
+
eventName: TEventName,
|
|
8
|
+
...eventArg: TEvents[TEventName]
|
|
9
|
+
) {
|
|
10
|
+
this.emitter.emit(eventName, ...(eventArg as []));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
on<TEventName extends keyof TEvents & string>(
|
|
14
|
+
eventName: TEventName,
|
|
15
|
+
handler: (...eventArg: TEvents[TEventName]) => void,
|
|
16
|
+
) {
|
|
17
|
+
this.emitter.on(eventName, handler as any);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
removeListener<TEventName extends keyof TEvents & string>(
|
|
21
|
+
eventName: TEventName,
|
|
22
|
+
handler: (...eventArg: TEvents[TEventName]) => void,
|
|
23
|
+
) {
|
|
24
|
+
this.emitter.removeListener(eventName, handler as any);
|
|
25
|
+
}
|
|
26
|
+
}
|