@tenminuteschool/auth-react 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.
Files changed (47) hide show
  1. package/dist/LoginButton.d.ts +36 -0
  2. package/dist/LoginButton.d.ts.map +1 -0
  3. package/dist/TenMSAuth.d.ts +78 -0
  4. package/dist/TenMSAuth.d.ts.map +1 -0
  5. package/dist/browser-standalone.d.ts +20 -0
  6. package/dist/browser-standalone.d.ts.map +1 -0
  7. package/dist/browser.d.ts +20 -0
  8. package/dist/browser.d.ts.map +1 -0
  9. package/dist/core/TenMSAuth.d.ts +86 -0
  10. package/dist/core/TenMSAuth.d.ts.map +1 -0
  11. package/dist/core/pkce.d.ts +33 -0
  12. package/dist/core/pkce.d.ts.map +1 -0
  13. package/dist/core/popup.d.ts +42 -0
  14. package/dist/core/popup.d.ts.map +1 -0
  15. package/dist/core/types.d.ts +66 -0
  16. package/dist/core/types.d.ts.map +1 -0
  17. package/dist/debug.d.ts +24 -0
  18. package/dist/debug.d.ts.map +1 -0
  19. package/dist/index.d.ts +23 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/log.d.ts +6 -0
  22. package/dist/log.d.ts.map +1 -0
  23. package/dist/logo.d.ts +12 -0
  24. package/dist/logo.d.ts.map +1 -0
  25. package/dist/mount.d.ts +29 -0
  26. package/dist/mount.d.ts.map +1 -0
  27. package/dist/pkce.d.ts +33 -0
  28. package/dist/pkce.d.ts.map +1 -0
  29. package/dist/popup.d.ts +42 -0
  30. package/dist/popup.d.ts.map +1 -0
  31. package/dist/react/LoginButton.d.ts +21 -0
  32. package/dist/react/LoginButton.d.ts.map +1 -0
  33. package/dist/tenms-auth.cjs.js +2 -0
  34. package/dist/tenms-auth.cjs.js.map +1 -0
  35. package/dist/tenms-auth.esm.js +2 -0
  36. package/dist/tenms-auth.esm.js.map +1 -0
  37. package/dist/tenms-auth.umd.js +2 -0
  38. package/dist/tenms-auth.umd.js.map +1 -0
  39. package/dist/types.d.ts +138 -0
  40. package/dist/types.d.ts.map +1 -0
  41. package/dist/ui/LoginButton.d.ts +36 -0
  42. package/dist/ui/LoginButton.d.ts.map +1 -0
  43. package/dist/ui/logo.d.ts +12 -0
  44. package/dist/ui/logo.d.ts.map +1 -0
  45. package/dist/utils/debug.d.ts +19 -0
  46. package/dist/utils/debug.d.ts.map +1 -0
  47. package/package.json +77 -0
@@ -0,0 +1,36 @@
1
+ import './LoginButton.css';
2
+ import type { LoginButtonOptions, TenMSAuthConfig } from './types';
3
+ interface RenderLoginButtonOptions extends TenMSAuthConfig, LoginButtonOptions {
4
+ }
5
+ declare const HTMLElementBase: typeof HTMLElement;
6
+ /**
7
+ * Custom element wrapper around the popup login flow.
8
+ *
9
+ * The component is intentionally thin: it reads attributes, constructs
10
+ * `TenMSAuth`, and emits success/error events so host applications stay in
11
+ * control of token exchange and post-login behavior.
12
+ */
13
+ export declare class TenMSLoginButtonElement extends HTMLElementBase {
14
+ private auth;
15
+ private loading;
16
+ static get observedAttributes(): string[];
17
+ connectedCallback(): void;
18
+ attributeChangedCallback(): void;
19
+ private render;
20
+ private handleClick;
21
+ private getConfig;
22
+ private dispatchError;
23
+ }
24
+ /**
25
+ * Registers `<tenms-login-button>` when running in a browser environment.
26
+ */
27
+ export declare function registerLoginButton(): void;
28
+ /**
29
+ * Imperatively mounts a styled login button into a container element.
30
+ *
31
+ * This is useful for plain HTML integrations that do not want to write the
32
+ * custom element markup themselves.
33
+ */
34
+ export declare function renderLoginButton(container: string | HTMLElement, options: RenderLoginButtonOptions): void;
35
+ export {};
36
+ //# sourceMappingURL=LoginButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoginButton.d.ts","sourceRoot":"","sources":["../src/LoginButton.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAI3B,OAAO,KAAK,EAEV,kBAAkB,EAClB,eAAe,EAChB,MAAM,SAAS,CAAC;AAMjB,UAAU,wBACR,SAAQ,eAAe,EAAE,kBAAkB;CAAG;AAKhD,QAAA,MAAM,eAAe,EACN,OAAO,WAAW,CAAC;AAElC;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D,OAAO,CAAC,IAAI,CAA0B;IACtC,OAAO,CAAC,OAAO,CAAS;IAExB,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAWxC;IAED,iBAAiB,IAAI,IAAI;IAIzB,wBAAwB,IAAI,IAAI;IAIhC,OAAO,CAAC,MAAM;YAoBA,WAAW;IAkCzB,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,aAAa;CAStB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAU1C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAAG,WAAW,EAC/B,OAAO,EAAE,wBAAwB,GAChC,IAAI,CA2DN"}
@@ -0,0 +1,78 @@
1
+ import { type AuthResponse, type PopupOptions, type TenMSAuthConfig, type TokenResponse, type UserInfo } from './types';
2
+ /**
3
+ * Main browser client for "Login with 10MinuteSchool".
4
+ *
5
+ * Handles the full browser-side OAuth 2.0 + PKCE flow: configuration,
6
+ * authorize URL construction, popup and redirect login, token exchange,
7
+ * userinfo, and token revocation.
8
+ *
9
+ * Pass `debug: true` in the config to enable verbose console logging at every
10
+ * step — useful during local integration without any extra tooling.
11
+ */
12
+ export declare class TenMSAuth {
13
+ private readonly config;
14
+ private readonly log;
15
+ constructor(config: TenMSAuthConfig);
16
+ /**
17
+ * Starts OAuth login in a popup window and returns the authorization code plus
18
+ * the PKCE verifier needed for the later token exchange.
19
+ *
20
+ * The popup is opened synchronously with `about:blank` before any `await`.
21
+ * Browsers treat that as a direct user gesture, which greatly reduces popup
22
+ * blocking compared with opening the final authorize URL after async work.
23
+ */
24
+ loginWithPopup(options?: PopupOptions): Promise<AuthResponse>;
25
+ /**
26
+ * Starts OAuth login by navigating the current window to the authorize URL.
27
+ *
28
+ * The PKCE verifier and state are written to `sessionStorage` first so the
29
+ * callback page can validate the response and recover the verifier needed for
30
+ * the later token exchange.
31
+ */
32
+ loginWithRedirect(): Promise<void>;
33
+ /**
34
+ * Parses the current URL as an OAuth redirect callback.
35
+ *
36
+ * Returns `null` when the current page does not look like a callback. When a
37
+ * callback is detected, the method validates `state`, restores the PKCE
38
+ * verifier from `sessionStorage`, clears temporary storage, and removes the
39
+ * query string from the URL.
40
+ */
41
+ handleRedirectCallback(): AuthResponse | null;
42
+ /**
43
+ * Exchanges an authorization code plus PKCE verifier for OAuth tokens.
44
+ *
45
+ * This helper is suitable for public browser clients that use PKCE. Server-side
46
+ * confidential clients should usually perform the token exchange on the
47
+ * backend, where a client secret can be kept private.
48
+ */
49
+ exchangeCode(code: string, codeVerifier: string): Promise<TokenResponse>;
50
+ /**
51
+ * Fetches the current user's profile from the OAuth userinfo endpoint.
52
+ */
53
+ getUserInfo(accessToken: string): Promise<UserInfo>;
54
+ /**
55
+ * Requests token revocation for a previously issued OAuth token.
56
+ *
57
+ * Some providers treat revocation as idempotent, so calling this for an
58
+ * already-invalid token may still return success. Non-OK responses still
59
+ * surface as structured SDK errors.
60
+ */
61
+ revokeToken(token: string): Promise<void>;
62
+ /**
63
+ * Returns the API base URL the client was configured with.
64
+ */
65
+ getBaseUrl(): string;
66
+ /**
67
+ * Returns the client identifier configured for this SDK instance.
68
+ */
69
+ getClientId(): string;
70
+ /**
71
+ * Builds the OAuth authorize URL for the current client configuration.
72
+ *
73
+ * Private — callers should not need to compose authorize requests manually;
74
+ * the public flow methods (`loginWithPopup`, `loginWithRedirect`) handle this.
75
+ */
76
+ private buildAuthorizeUrl;
77
+ }
78
+ //# sourceMappingURL=TenMSAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TenMSAuth.d.ts","sourceRoot":"","sources":["../src/TenMSAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,QAAQ,EAEd,MAAM,SAAS,CAAC;AAuBjB;;;;;;;;;GASG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4B;IACnD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;gBAEjB,MAAM,EAAE,eAAe;IAcnC;;;;;;;OAOG;IACG,cAAc,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAyEvE;;;;;;OAMG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBxC;;;;;;;OAOG;IACH,sBAAsB,IAAI,YAAY,GAAG,IAAI;IA8E7C;;;;;;OAMG;IACG,YAAY,CAChB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,CAAC;IA6DzB;;OAEG;IACG,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAsCzD;;;;;;OAMG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkC/C;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CAW1B"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Browser/CDN entry point — no React dependency.
3
+ *
4
+ * Exported as the UMD bundle (tenms-auth.umd.js) for direct <script> usage.
5
+ * React consumers should use the npm package instead:
6
+ * import { LoginButton } from '@10minuteschool/auth';
7
+ */
8
+ export declare const VERSION = "0.1.0";
9
+ export { TenMSAuth } from './core/TenMSAuth';
10
+ export type { AuthResponse, LoginButtonOptions, PopupOptions, TenMSAuthConfig, TokenResponse, UserInfo, } from './core/types';
11
+ export { TenMSAuthError } from './core/types';
12
+ export { generateCodeChallenge, generateCodeVerifier, generateState, } from './core/pkce';
13
+ export { createLogger, truncate } from './utils/debug';
14
+ export type { Logger } from './utils/debug';
15
+ export type { PopupConfig, PopupRedirectResult } from './core/popup';
16
+ export { openPopup, waitForPopupRedirect } from './core/popup';
17
+ export { TenMSLoginButtonElement, registerLoginButton, renderLoginButton, } from './ui/LoginButton';
18
+ export { mount } from './mount';
19
+ export type { MountOptions, MountInstance } from './mount';
20
+ //# sourceMappingURL=browser-standalone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-standalone.d.ts","sourceRoot":"","sources":["../src/browser-standalone.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Browser/CDN entry point — no React dependency.
3
+ *
4
+ * Exported as the UMD bundle (tenms-auth.umd.js) for direct <script> usage.
5
+ * React consumers should use the npm package instead:
6
+ * import { LoginButton } from '@10minuteschool/auth';
7
+ */
8
+ export declare const VERSION = "0.1.0";
9
+ export { TenMSAuth } from './core/TenMSAuth';
10
+ export type { AuthResponse, LoginButtonOptions, PopupOptions, TenMSAuthConfig, TokenResponse, UserInfo, } from './core/types';
11
+ export { TenMSAuthError } from './core/types';
12
+ export { generateCodeChallenge, generateCodeVerifier, generateState, } from './core/pkce';
13
+ export { createLogger, truncate } from './utils/debug';
14
+ export type { Logger } from './utils/debug';
15
+ export type { PopupConfig, PopupRedirectResult } from './core/popup';
16
+ export { openPopup, waitForPopupRedirect } from './core/popup';
17
+ export { TenMSLoginButtonElement, registerLoginButton, renderLoginButton, } from './ui/LoginButton';
18
+ export { LoginButton } from './react/LoginButton';
19
+ export type { LoginButtonProps } from './react/LoginButton';
20
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { type AuthResponse, type PopupOptions, type TenMSAuthConfig, type TokenResponse, type UserInfo } from './types';
2
+ /**
3
+ * Main browser client for "Login with 10MinuteSchool".
4
+ *
5
+ * Handles the full browser-side OAuth 2.0 + PKCE flow: configuration,
6
+ * authorize URL construction, popup and redirect login, token exchange,
7
+ * userinfo, and token revocation.
8
+ *
9
+ * Pass `debug: true` in the config to enable verbose console logging at every
10
+ * step — useful during local integration without any extra tooling.
11
+ */
12
+ export declare class TenMSAuth {
13
+ private readonly config;
14
+ private readonly log;
15
+ constructor(config: TenMSAuthConfig);
16
+ /**
17
+ * Starts OAuth login in a popup window and returns the authorization code plus
18
+ * the PKCE verifier needed for the later token exchange.
19
+ *
20
+ * The popup is opened synchronously with `about:blank` before any `await`.
21
+ * Browsers treat that as a direct user gesture, which greatly reduces popup
22
+ * blocking compared with opening the final authorize URL after async work.
23
+ */
24
+ loginWithPopup(options?: PopupOptions): Promise<AuthResponse>;
25
+ /**
26
+ * Starts OAuth login by navigating the current window to the authorize URL.
27
+ *
28
+ * The PKCE verifier and state are written to `sessionStorage` first so the
29
+ * callback page can validate the response and recover the verifier needed for
30
+ * the later token exchange.
31
+ */
32
+ loginWithRedirect(): Promise<void>;
33
+ /**
34
+ * Parses the current URL as an OAuth redirect callback.
35
+ *
36
+ * Returns `null` when the current page does not look like a callback. When a
37
+ * callback is detected, the method validates `state`, restores the PKCE
38
+ * verifier from `sessionStorage`, clears temporary storage, and removes the
39
+ * query string from the URL.
40
+ */
41
+ handleRedirectCallback(): AuthResponse | null;
42
+ /**
43
+ * Exchanges an authorization code plus PKCE verifier for OAuth tokens.
44
+ *
45
+ * This helper is suitable for public browser clients that use PKCE. Server-side
46
+ * confidential clients should usually perform the token exchange on the
47
+ * backend, where a client secret can be kept private.
48
+ */
49
+ exchangeCode(code: string, codeVerifier: string): Promise<TokenResponse>;
50
+ /**
51
+ * Exchanges a refresh token for a fresh set of OAuth tokens.
52
+ *
53
+ * The caller is responsible for storing and securing the refresh token.
54
+ * For browser clients, prefer short-lived access tokens and re-authenticate
55
+ * via popup rather than storing long-lived refresh tokens in browser storage.
56
+ */
57
+ refreshToken(refreshToken: string): Promise<TokenResponse>;
58
+ /**
59
+ * Fetches the current user's profile from the OAuth userinfo endpoint.
60
+ */
61
+ getUserInfo(accessToken: string): Promise<UserInfo>;
62
+ /**
63
+ * Requests token revocation for a previously issued OAuth token.
64
+ *
65
+ * Some providers treat revocation as idempotent, so calling this for an
66
+ * already-invalid token may still return success. Non-OK responses still
67
+ * surface as structured SDK errors.
68
+ */
69
+ revokeToken(token: string): Promise<void>;
70
+ /**
71
+ * Returns the API base URL the client was configured with.
72
+ */
73
+ getBaseUrl(): string;
74
+ /**
75
+ * Returns the client identifier configured for this SDK instance.
76
+ */
77
+ getClientId(): string;
78
+ /**
79
+ * Builds the OAuth authorize URL for the current client configuration.
80
+ *
81
+ * Private — callers should not need to compose authorize requests manually;
82
+ * the public flow methods (`loginWithPopup`, `loginWithRedirect`) handle this.
83
+ */
84
+ private buildAuthorizeUrl;
85
+ }
86
+ //# sourceMappingURL=TenMSAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TenMSAuth.d.ts","sourceRoot":"","sources":["../../src/core/TenMSAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,QAAQ,EAEd,MAAM,SAAS,CAAC;AAwBjB;;;;;;;;;GASG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4B;IACnD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;gBAEjB,MAAM,EAAE,eAAe;IAcnC;;;;;;;OAOG;IACG,cAAc,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAyEvE;;;;;;OAMG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBxC;;;;;;;OAOG;IACH,sBAAsB,IAAI,YAAY,GAAG,IAAI;IA8E7C;;;;;;OAMG;IACG,YAAY,CAChB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,CAAC;IA8DzB;;;;;;OAMG;IACG,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAgDhE;;OAEG;IACG,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAyCzD;;;;;;OAMG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC/C;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;CAW1B"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * PKCE helpers for OAuth 2.0 authorization code flow.
3
+ *
4
+ * RFC 7636 requires a `code_verifier` made from "unreserved" URL-safe
5
+ * characters and a `code_challenge` derived from it. These helpers intentionally
6
+ * stay framework-agnostic so they can be used by both the main SDK client and
7
+ * advanced consumers who need lower-level control.
8
+ */
9
+ /**
10
+ * Generates a PKCE `code_verifier` using the RFC 7636 unreserved character set.
11
+ *
12
+ * The returned string is URL-safe and defaults to 64 characters, which is well
13
+ * within the 43-128 character range accepted by compliant OAuth servers.
14
+ *
15
+ * Rejection sampling is used to eliminate modulo bias. Since PKCE_CHARSET has
16
+ * 66 characters and a random byte has 256 possible values, naïve `byte % 66`
17
+ * would make the first 58 characters ~33 % more likely than the last 8. We
18
+ * discard bytes that fall in the remainder region so every character is chosen
19
+ * with equal probability.
20
+ */
21
+ export declare function generateCodeVerifier(length?: number): string;
22
+ /**
23
+ * Derives the S256 `code_challenge` from a PKCE verifier.
24
+ */
25
+ export declare function generateCodeChallenge(codeVerifier: string): Promise<string>;
26
+ /**
27
+ * Generates a URL-safe random state token for CSRF protection.
28
+ *
29
+ * Hex encoding keeps the value compact, easy to log in development, and safe to
30
+ * place in query strings without extra escaping.
31
+ */
32
+ export declare function generateState(byteLength?: number): string;
33
+ //# sourceMappingURL=pkce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../src/core/pkce.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,SAA0B,GAAG,MAAM,CA2B7E;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,SAAsB,GAAG,MAAM,CAStE"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Parameters used to open a centered OAuth popup window.
3
+ */
4
+ export interface PopupConfig {
5
+ /** Initial URL to load in the popup. */
6
+ url: string;
7
+ /** Popup width in pixels. */
8
+ width: number;
9
+ /** Popup height in pixels. */
10
+ height: number;
11
+ }
12
+ /**
13
+ * Data collected from the popup once it reaches the registered redirect URI.
14
+ */
15
+ export interface PopupRedirectResult {
16
+ /** Authorization code returned by the OAuth server. */
17
+ code: string;
18
+ /** State value echoed back by the OAuth server. */
19
+ state: string;
20
+ }
21
+ /**
22
+ * Opens a centered popup window for the OAuth flow.
23
+ *
24
+ * Returning `null` means the browser blocked the popup, which usually happens
25
+ * when `window.open` is called outside a direct user interaction.
26
+ */
27
+ export declare function openPopup(config: PopupConfig): Window | null;
28
+ /**
29
+ * Polls the popup until it lands on the application's redirect URI.
30
+ *
31
+ * The opener may only read `popup.location` when the popup is **same-origin**.
32
+ * So `redirectUri` must use the same scheme/host/port as the page that called
33
+ * `loginWithPopup` (e.g. `new URL(location.pathname, location.origin).href`).
34
+ * If `redirectUri` points at another domain, polling stays cross-origin and this
35
+ * promise will time out after login.
36
+ *
37
+ * This does not require cooperation from the identity provider while it is
38
+ * cross-origin. Once the popup navigates to your redirect URI on the opener
39
+ * origin, parameters are read, validated, and the window is closed.
40
+ */
41
+ export declare function waitForPopupRedirect(popup: Window, redirectUri: string, expectedState: string, timeoutMs?: number): Promise<PopupRedirectResult>;
42
+ //# sourceMappingURL=popup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../../src/core/popup.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IAEZ,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IAEd,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAKD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CA6B5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,SAAS,SAAqB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAmH9B"}
@@ -0,0 +1,66 @@
1
+ /** Runtime configuration for the browser SDK. */
2
+ export interface TenMSAuthConfig {
3
+ clientId: string;
4
+ /**
5
+ * Redirect URI registered for the client.
6
+ *
7
+ * For popup flows, it must be same-origin as the opener so the SDK can read
8
+ * `popup.location` after the provider redirects back with `code` and `state`.
9
+ */
10
+ redirectUri: string;
11
+ scopes?: string[];
12
+ /**
13
+ * Enable verbose debug logging to the browser console.
14
+ *
15
+ * When enabled, the SDK logs each major OAuth step and truncates sensitive
16
+ * values before printing them.
17
+ */
18
+ debug?: boolean;
19
+ }
20
+ /** Result returned after authorization completes. */
21
+ export interface AuthResponse {
22
+ code: string;
23
+ state: string;
24
+ codeVerifier: string;
25
+ }
26
+ /** Profile payload returned from `/v1/oauth/userinfo`. */
27
+ export interface UserInfo {
28
+ sub: string;
29
+ name?: string;
30
+ email?: string;
31
+ phone?: string;
32
+ picture?: string;
33
+ email_verified?: boolean;
34
+ phone_verified?: boolean;
35
+ }
36
+ /** JSON payload returned from `/v1/oauth/token`. */
37
+ export interface TokenResponse {
38
+ access_token: string;
39
+ token_type: string;
40
+ expires_in: number;
41
+ refresh_token?: string;
42
+ scope: string;
43
+ user?: UserInfo;
44
+ }
45
+ /** Presentation options for the popup window. */
46
+ export interface PopupOptions {
47
+ width?: number;
48
+ height?: number;
49
+ }
50
+ /** Customization hooks shared by the packaged login button integrations. */
51
+ export interface LoginButtonOptions {
52
+ theme?: 'dark' | 'light' | 'outline';
53
+ size?: 'small' | 'medium' | 'large';
54
+ text?: string;
55
+ onSuccess?: (response: AuthResponse) => void;
56
+ onError?: (error: Error) => void;
57
+ }
58
+ /**
59
+ * Structured error used by the SDK so callers can branch on a stable `code`
60
+ * instead of relying on message text.
61
+ */
62
+ export declare class TenMSAuthError extends Error {
63
+ readonly code: string;
64
+ constructor(message: string, code: string);
65
+ }
66
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,0DAA0D;AAC1D,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACrC,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;IAC7C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAQ1C"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Structured debug logger for the @10minuteschool/auth SDK.
3
+ *
4
+ * Enable per-instance by passing `debug: true` in `TenMSAuthConfig`. Nothing
5
+ * is emitted when `debug` is absent or `false`, so there is zero runtime cost
6
+ * in production.
7
+ *
8
+ * Output uses the browser DevTools console with collapsible groups for props,
9
+ * making it easy to inspect every parameter at each step of the OAuth flow.
10
+ */
11
+ export interface Logger {
12
+ info(event: string, props?: Record<string, unknown>): void;
13
+ warn(event: string, props?: Record<string, unknown>): void;
14
+ error(event: string, err?: unknown): void;
15
+ }
16
+ /** Returns a no-op logger when `enabled` is false (production path). */
17
+ export declare function createLogger(enabled: boolean): Logger;
18
+ /**
19
+ * Truncates a sensitive string (token, code, verifier) to the first 8
20
+ * characters followed by `…`. Keeps logs readable without leaking full values
21
+ * to DevTools recordings or bug reports.
22
+ */
23
+ export declare function truncate(value: string): string;
24
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3D,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3C;AAID,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAErD;AAqCD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG9C"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Public entrypoint for the @10minuteschool/auth browser SDK.
4
+ */
5
+ /** Current SDK version. */
6
+ export declare const VERSION = "0.1.0";
7
+ export { TenMSAuth } from './core/TenMSAuth';
8
+ /** Public types and error contract. */
9
+ export type { AuthResponse, LoginButtonOptions, PopupOptions, TenMSAuthConfig, TokenResponse, UserInfo, } from './core/types';
10
+ export { TenMSAuthError } from './core/types';
11
+ /** Low-level PKCE helpers. */
12
+ export { generateCodeChallenge, generateCodeVerifier, generateState, } from './core/pkce';
13
+ /** Optional debug helpers. */
14
+ export { createLogger, truncate } from './utils/debug';
15
+ export type { Logger } from './utils/debug';
16
+ /** Low-level popup helpers. */
17
+ export type { PopupConfig, PopupRedirectResult } from './core/popup';
18
+ export { openPopup, waitForPopupRedirect } from './core/popup';
19
+ /** Prebuilt UI integrations. */
20
+ export { TenMSLoginButtonElement, registerLoginButton, renderLoginButton, } from './ui/LoginButton';
21
+ export { LoginButton } from './react/LoginButton';
22
+ export type { LoginButtonProps } from './react/LoginButton';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,2BAA2B;AAC3B,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,uCAAuC;AACvC,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,8BAA8B;AAC9B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,8BAA8B;AAC9B,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,+BAA+B;AAC/B,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE/D,gCAAgC;AAChC,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/log.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Opt-in console logging for tracing OAuth / UI flows. Enable with
3
+ * `debug: true` on {@link TenMSAuthConfig}.
4
+ */
5
+ export declare function tenmsDebug(enabled: boolean, scope: string, message: string, detail?: unknown): void;
6
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,OAAO,GACf,IAAI,CAQN"}
package/dist/logo.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Small inline logo used by the packaged login button.
3
+ *
4
+ * This is the official 10 Minute School mark, inlined so the package stays
5
+ * self-contained and does not depend on a remote CDN at runtime.
6
+ */
7
+ export declare const TENMS_LOGO_SVG = "<svg viewBox=\"0 0 35 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" focusable=\"false\">\n <g clip-path=\"url(#tenms-logo-clip)\">\n <path d=\"M25.2166 18.6611L34.4336 9.44259C33.4258 4.52089 29.5119 0.657436 24.5531 0.0370282C24.4596 0.0251544 24.3646 0.0147648 24.2711 0.00585938V4.5758C26.4188 4.93944 28.1999 6.32868 29.2388 8.24037L22.0195 15.4582L25.2166 18.6611Z\" fill=\"#EB2026\"/>\n <path d=\"M8.63228 32H4.09944V4.53284H0V0H8.63228V32Z\" fill=\"white\"/>\n <path d=\"M30.1299 16.9588L30.1106 19.9718V19.9866C30.1106 24.1083 26.9729 27.4612 23.1169 27.4612C19.2609 27.4612 16.1262 24.1113 16.1232 19.994L16.1781 11.9718V11.9569C16.1781 8.29385 18.6657 5.17994 22.0126 4.58476V0.0103635L21.7158 0.0445008C15.9703 0.79849 11.6423 5.91611 11.6379 11.9495L11.5859 19.9718V19.9866C11.5859 26.6078 16.757 31.994 23.1124 31.994C29.4679 31.994 34.6345 26.6122 34.6375 19.994L34.688 12.3963L30.1299 16.9588Z\" fill=\"white\"/>\n </g>\n <defs>\n <clipPath id=\"tenms-logo-clip\">\n <rect width=\"35\" height=\"32\" fill=\"white\"/>\n </clipPath>\n </defs>\n</svg>";
8
+ /**
9
+ * Returns the full HTML fragment used by the non-React button renderers.
10
+ */
11
+ export declare function getLogoHtml(): string;
12
+ //# sourceMappingURL=logo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logo.d.ts","sourceRoot":"","sources":["../src/logo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,cAAc,mmCAWpB,CAAC;AAER;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
@@ -0,0 +1,29 @@
1
+ import type { TenMSAuthConfig, LoginButtonOptions } from './core/types';
2
+ export interface MountOptions extends TenMSAuthConfig, LoginButtonOptions {
3
+ theme?: 'dark' | 'light' | 'outline';
4
+ size?: 'small' | 'medium' | 'large';
5
+ text?: string;
6
+ }
7
+ export interface MountInstance {
8
+ /** Unmounts the button and cleans up the React root. */
9
+ unmount: () => void;
10
+ }
11
+ /**
12
+ * Mounts the login button into any DOM container using an isolated React root.
13
+ *
14
+ * Works in plain HTML, React, Vue, Angular — any environment.
15
+ * The host app does not need React. The SDK manages its own React tree.
16
+ *
17
+ * @example
18
+ * const btn = TenMSAuth.mount('#login-container', {
19
+ * clientId: 'YOUR_CLIENT_ID',
20
+ * redirectUri: window.location.href,
21
+ * onSuccess: async ({ code, codeVerifier }) => { ... },
22
+ * onError: (err) => console.error(err),
23
+ * });
24
+ *
25
+ * // Later, to clean up:
26
+ * btn.unmount();
27
+ */
28
+ export declare function mount(container: string | HTMLElement, options: MountOptions): MountInstance;
29
+ //# sourceMappingURL=mount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAExE,MAAM,WAAW,YAAa,SAAQ,eAAe,EAAE,kBAAkB;IACvE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACrC,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CACnB,SAAS,EAAE,MAAM,GAAG,WAAW,EAC/B,OAAO,EAAE,YAAY,GACpB,aAAa,CAkBf"}
package/dist/pkce.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * PKCE helpers for OAuth 2.0 authorization code flow.
3
+ *
4
+ * RFC 7636 requires a `code_verifier` made from "unreserved" URL-safe
5
+ * characters and a `code_challenge` derived from it. These helpers intentionally
6
+ * stay framework-agnostic so they can be used by both the main SDK client and
7
+ * advanced consumers who need lower-level control.
8
+ */
9
+ /**
10
+ * Generates a PKCE `code_verifier` using the RFC 7636 unreserved character set.
11
+ *
12
+ * The returned string is URL-safe and defaults to 64 characters, which is well
13
+ * within the 43-128 character range accepted by compliant OAuth servers.
14
+ *
15
+ * Rejection sampling is used to eliminate modulo bias. Since PKCE_CHARSET has
16
+ * 66 characters and a random byte has 256 possible values, naïve `byte % 66`
17
+ * would make the first 58 characters ~33 % more likely than the last 8. We
18
+ * discard bytes that fall in the remainder region so every character is chosen
19
+ * with equal probability.
20
+ */
21
+ export declare function generateCodeVerifier(length?: number): string;
22
+ /**
23
+ * Derives the S256 `code_challenge` from a PKCE verifier.
24
+ */
25
+ export declare function generateCodeChallenge(codeVerifier: string): Promise<string>;
26
+ /**
27
+ * Generates a URL-safe random state token for CSRF protection.
28
+ *
29
+ * Hex encoding keeps the value compact, easy to log in development, and safe to
30
+ * place in query strings without extra escaping.
31
+ */
32
+ export declare function generateState(byteLength?: number): string;
33
+ //# sourceMappingURL=pkce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../src/pkce.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,SAA0B,GAAG,MAAM,CA2B7E;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,SAAsB,GAAG,MAAM,CAStE"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Parameters used to open a centered OAuth popup window.
3
+ */
4
+ export interface PopupConfig {
5
+ /** Initial URL to load in the popup. */
6
+ url: string;
7
+ /** Popup width in pixels. */
8
+ width: number;
9
+ /** Popup height in pixels. */
10
+ height: number;
11
+ }
12
+ /**
13
+ * Data collected from the popup once it reaches the registered redirect URI.
14
+ */
15
+ export interface PopupRedirectResult {
16
+ /** Authorization code returned by the OAuth server. */
17
+ code: string;
18
+ /** State value echoed back by the OAuth server. */
19
+ state: string;
20
+ }
21
+ /**
22
+ * Opens a centered popup window for the OAuth flow.
23
+ *
24
+ * Returning `null` means the browser blocked the popup, which usually happens
25
+ * when `window.open` is called outside a direct user interaction.
26
+ */
27
+ export declare function openPopup(config: PopupConfig): Window | null;
28
+ /**
29
+ * Polls the popup until it lands on the application's redirect URI.
30
+ *
31
+ * The opener may only read `popup.location` when the popup is **same-origin**.
32
+ * So `redirectUri` must use the same scheme/host/port as the page that called
33
+ * `loginWithPopup` (e.g. `new URL('oauth-callback.html', location.href).href`).
34
+ * If `redirectUri` points at another domain, polling stays cross-origin and this
35
+ * promise will time out after login.
36
+ *
37
+ * This does not require cooperation from the identity provider while it is
38
+ * cross-origin. Once the popup navigates to your redirect URI on the opener
39
+ * origin, parameters are read, validated, and the window is closed.
40
+ */
41
+ export declare function waitForPopupRedirect(popup: Window, redirectUri: string, expectedState: string, timeoutMs?: number): Promise<PopupRedirectResult>;
42
+ //# sourceMappingURL=popup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popup.d.ts","sourceRoot":"","sources":["../src/popup.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IAEZ,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IAEd,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAKD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CA6B5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,SAAS,SAAqB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAmH9B"}