@flowsta/login-button 0.1.1 → 0.1.3

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,26 @@
1
+ /**
2
+ * Flowsta Login Button - React Component
3
+ */
4
+ import type { FlowstaLoginButtonProps } from './types.js';
5
+ /**
6
+ * Flowsta Login Button component for React
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * <FlowstaLoginButton
11
+ * clientId="your-client-id"
12
+ * redirectUri="https://yourapp.com/callback"
13
+ * scopes={['openid', 'email', 'display_name']}
14
+ * variant="dark-pill"
15
+ * onSuccess={(data) => {
16
+ * console.log('Authorization code:', data.code);
17
+ * }}
18
+ * onError={(error) => {
19
+ * console.error('Login error:', error);
20
+ * }}
21
+ * />
22
+ * ```
23
+ */
24
+ export declare function FlowstaLoginButton({ clientId, redirectUri, scopes, variant, loginUrl, className, disabled, onSuccess, onError, onClick, children, }: FlowstaLoginButtonProps): JSX.Element;
25
+ export default FlowstaLoginButton;
26
+ //# sourceMappingURL=FlowstaLoginButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowstaLoginButton.d.ts","sourceRoot":"","sources":["../src/FlowstaLoginButton.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAI1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,WAAW,EACX,MAA4C,EAC5C,OAAqB,EACrB,QAAQ,EACR,SAAc,EACd,QAAgB,EAChB,SAAS,EACT,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CAkEvC;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Flowsta Login Button - Qwik Component
3
+ * @jsxImportSource @builder.io/qwik
4
+ */
5
+ import type { FlowstaLoginConfig, FlowstaLoginSuccess, FlowstaLoginError } from './types.js';
6
+ export interface FlowstaLoginButtonQwikProps extends FlowstaLoginConfig {
7
+ /** Callback when login succeeds */
8
+ onSuccess$?: (data: FlowstaLoginSuccess) => void;
9
+ /** Callback when login fails */
10
+ onError$?: (error: FlowstaLoginError) => void;
11
+ /** Callback when button is clicked (before redirect) */
12
+ onClick$?: () => void;
13
+ /** Custom CSS class name */
14
+ class?: string;
15
+ }
16
+ /**
17
+ * Flowsta Login Button component for Qwik
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * import { FlowstaLoginButton } from '@flowsta/login-button/qwik';
22
+ *
23
+ * export default component$(() => {
24
+ * return (
25
+ * <FlowstaLoginButton
26
+ * clientId="your-client-id"
27
+ * redirectUri="https://yourapp.com/callback"
28
+ * scopes={['openid', 'email', 'display_name']}
29
+ * variant="dark-pill"
30
+ * onSuccess$={(data) => {
31
+ * console.log('Authorization code:', data.code);
32
+ * }}
33
+ * onError$={(error) => {
34
+ * console.error('Login error:', error);
35
+ * }}
36
+ * />
37
+ * );
38
+ * });
39
+ * ```
40
+ */
41
+ export declare const FlowstaLoginButton: import("@builder.io/qwik").Component<FlowstaLoginButtonQwikProps>;
42
+ export default FlowstaLoginButton;
43
+ //# sourceMappingURL=FlowstaLoginButtonQwik.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowstaLoginButtonQwik.d.ts","sourceRoot":"","sources":["../src/FlowstaLoginButtonQwik.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG7F,MAAM,WAAW,2BAA4B,SAAQ,kBAAkB;IACrE,mCAAmC;IACnC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAEjD,gCAAgC;IAChC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAE9C,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAEtB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,kBAAkB,mEAkF7B,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Flowsta Login Button - Vanilla JavaScript
3
+ */
4
+ import type { FlowstaLoginConfig, FlowstaLoginSuccess, FlowstaLoginError } from './types.js';
5
+ export interface FlowstaLoginButtonVanillaOptions extends FlowstaLoginConfig {
6
+ /** Callback when login succeeds */
7
+ onSuccess?: (data: FlowstaLoginSuccess) => void;
8
+ /** Callback when login fails */
9
+ onError?: (error: FlowstaLoginError) => void;
10
+ /** Callback when button is clicked (before redirect) */
11
+ onClick?: () => void;
12
+ }
13
+ /**
14
+ * Create a Flowsta login button element
15
+ *
16
+ * @example
17
+ * ```javascript
18
+ * import { createFlowstaLoginButton } from '@flowsta/login-button/vanilla';
19
+ *
20
+ * const button = createFlowstaLoginButton({
21
+ * clientId: 'your-client-id',
22
+ * redirectUri: 'https://yourapp.com/callback',
23
+ * scopes: ['openid', 'email', 'display_name'],
24
+ * variant: 'dark-pill',
25
+ * onSuccess: (data) => {
26
+ * console.log('Authorization code:', data.code);
27
+ * },
28
+ * onError: (error) => {
29
+ * console.error('Login error:', error);
30
+ * }
31
+ * });
32
+ *
33
+ * document.getElementById('login-container').appendChild(button);
34
+ * ```
35
+ */
36
+ export declare function createFlowstaLoginButton(options: FlowstaLoginButtonVanillaOptions): HTMLButtonElement;
37
+ /**
38
+ * Initialize Flowsta login button in a container element
39
+ *
40
+ * @example
41
+ * ```javascript
42
+ * import { initFlowstaLoginButton } from '@flowsta/login-button/vanilla';
43
+ *
44
+ * initFlowstaLoginButton('#login-button-container', {
45
+ * clientId: 'your-client-id',
46
+ * redirectUri: 'https://yourapp.com/callback',
47
+ * scopes: ['openid', 'email', 'display_name'],
48
+ * variant: 'dark-pill'
49
+ * });
50
+ * ```
51
+ */
52
+ export declare function initFlowstaLoginButton(selector: string | HTMLElement, options: FlowstaLoginButtonVanillaOptions): HTMLButtonElement;
53
+ declare const _default: {
54
+ createFlowstaLoginButton: typeof createFlowstaLoginButton;
55
+ initFlowstaLoginButton: typeof initFlowstaLoginButton;
56
+ };
57
+ export default _default;
58
+ //# sourceMappingURL=FlowstaLoginButtonVanilla.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowstaLoginButtonVanilla.d.ts","sourceRoot":"","sources":["../src/FlowstaLoginButtonVanilla.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG7F,MAAM,WAAW,gCAAiC,SAAQ,kBAAkB;IAC1E,mCAAmC;IACnC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAEhD,gCAAgC;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAE7C,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,gCAAgC,GACxC,iBAAiB,CAoFnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAC9B,OAAO,EAAE,gCAAgC,GACxC,iBAAiB,CAanB;;;;;AAED,wBAGE"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Flowsta Login Button Assets
3
+ *
4
+ * Industry-standard approach: Ship assets with npm package
5
+ * - Works automatically with all modern bundlers (Vite, Webpack, Parcel, etc.)
6
+ * - Zero configuration required
7
+ * - Falls back to CDN if needed
8
+ *
9
+ * Usage:
10
+ * ```tsx
11
+ * import { getButtonUrl } from '@flowsta/login-button';
12
+ *
13
+ * <img src={getButtonUrl('dark', 'pill')} alt="Sign in with Flowsta" />
14
+ * ```
15
+ */
16
+ export type ButtonTheme = 'dark' | 'light' | 'neutral';
17
+ export type ButtonShape = 'pill' | 'rectangle';
18
+ /**
19
+ * Get button asset URL
20
+ *
21
+ * @param theme - 'dark' (for light backgrounds), 'light' (for dark backgrounds), or 'neutral' (for any background)
22
+ * @param shape - 'pill' (rounded) or 'rectangle' (square corners)
23
+ * @returns URL to button SVG
24
+ */
25
+ export declare function getButtonUrl(theme: ButtonTheme, shape: ButtonShape): string;
26
+ /**
27
+ * Pre-made button URLs for all combinations
28
+ */
29
+ export declare const BUTTON_URLS: {
30
+ readonly dark: {
31
+ readonly pill: string;
32
+ readonly rectangle: string;
33
+ };
34
+ readonly light: {
35
+ readonly pill: string;
36
+ readonly rectangle: string;
37
+ };
38
+ readonly neutral: {
39
+ readonly pill: string;
40
+ readonly rectangle: string;
41
+ };
42
+ };
43
+ //# sourceMappingURL=buttonAssets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buttonAssets.d.ts","sourceRoot":"","sources":["../src/buttonAssets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AACvD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAW3E;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAad,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @flowsta/login-button
3
+ *
4
+ * Login with Flowsta button components for React, Vue, and vanilla JavaScript
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export * from './utils/pkce.js';
9
+ export * from './utils/state.js';
10
+ export * from './utils/oauth.js';
11
+ export * from './types.js';
12
+ export * from './buttonAssets.js';
13
+ export { buildAuthorizationUrl, handleCallback, parseCallbackUrl } from './utils/oauth.js';
14
+ export { generatePKCEPair, generateCodeVerifier, generateCodeChallenge } from './utils/pkce.js';
15
+ export { generateState, validateState } from './utils/state.js';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,YAAY,CAAC;AAG3B,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b as i, a as g, g as o, c, d as p, h as u, p as d, r as f, f as h, s as C, e as b, v } from "./oauth-DEOZXwxb.js";
1
+ import { b as i, g, a as o, c, d as p, h as u, p as d, r as f, e as h, s as C, f as b, v } from "./oauth-DieOmaFh.js";
2
2
  function e(a, r) {
3
3
  const t = `flowsta_signin_web_${a}_${r}.svg`;
4
4
  try {
@@ -85,13 +85,13 @@ function S() {
85
85
  return h(window.location.href);
86
86
  }
87
87
  export {
88
- c as a,
88
+ i as a,
89
89
  m as b,
90
90
  l as c,
91
91
  u as d,
92
- f as e,
93
- _ as f,
94
- i as g,
92
+ _ as e,
93
+ f,
94
+ c as g,
95
95
  S as h,
96
96
  h as p,
97
97
  v as r,
package/dist/qwik.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @flowsta/login-button/qwik
3
+ *
4
+ * Qwik components for Flowsta login
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export { FlowstaLoginButton, default } from './FlowstaLoginButtonQwik.js';
9
+ export type { FlowstaLoginButtonQwikProps } from './FlowstaLoginButtonQwik.js';
10
+ export * from './utils/oauth.js';
11
+ export * from './types.js';
12
+ //# sourceMappingURL=qwik.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qwik.d.ts","sourceRoot":"","sources":["../src/qwik.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC1E,YAAY,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAG/E,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
package/dist/qwik.js CHANGED
@@ -1,53 +1,53 @@
1
1
  import { jsx as n } from "@builder.io/qwik/jsx-runtime";
2
- import { component$ as m, useSignal as h, $ as w } from "@builder.io/qwik";
3
- import { b } from "./oauth-DEOZXwxb.js";
4
- import { h as S, p as F } from "./oauth-DEOZXwxb.js";
5
- const C = m((e) => {
2
+ import { component$ as f, useSignal as h, $ as w } from "@builder.io/qwik";
3
+ import { b } from "./oauth-DieOmaFh.js";
4
+ import { h as S, p as F } from "./oauth-DieOmaFh.js";
5
+ const C = f((t) => {
6
6
  const {
7
- clientId: r,
8
- redirectUri: i,
9
- scopes: l = ["profile"],
7
+ clientId: i,
8
+ redirectUri: r,
9
+ scopes: l = ["openid", "email", "display_name"],
10
10
  variant: s = "dark-pill",
11
11
  loginUrl: c,
12
12
  className: d = "",
13
- disabled: t = !1,
14
- onSuccess$: k,
13
+ disabled: o = !1,
14
+ onSuccess$: y,
15
15
  onError$: u,
16
16
  onClick$: g
17
- } = e, a = h(!1), f = w(async () => {
18
- if (!(t || a.value)) {
17
+ } = t, a = h(!1), m = w(async () => {
18
+ if (!(o || a.value)) {
19
19
  a.value = !0;
20
20
  try {
21
21
  g?.();
22
- const { url: o } = await b({
23
- clientId: r,
24
- redirectUri: i,
22
+ const { url: e } = await b({
23
+ clientId: i,
24
+ redirectUri: r,
25
25
  scopes: l,
26
26
  loginUrl: c
27
27
  });
28
- typeof window < "u" && (window.location.href = o);
29
- } catch (o) {
28
+ typeof window < "u" && (window.location.href = e);
29
+ } catch (e) {
30
30
  a.value = !1, u?.({
31
31
  error: "authorization_failed",
32
- errorDescription: o instanceof Error ? o.message : "Unknown error"
32
+ errorDescription: e instanceof Error ? e.message : "Unknown error"
33
33
  });
34
34
  }
35
35
  }
36
- }), p = (o) => `/node_modules/@flowsta/login-button/assets/svg/${`flowsta_signin_web_${o.replace("-", "_")}`}.svg`;
36
+ }), p = (e) => `/node_modules/@flowsta/login-button/assets/svg/${`flowsta_signin_web_${e.replace("-", "_")}`}.svg`;
37
37
  return /* @__PURE__ */ n(
38
38
  "button",
39
39
  {
40
40
  type: "button",
41
- onClick$: f,
42
- disabled: t || a.value,
43
- class: `flowsta-login-button ${d || e.class || ""}`,
41
+ onClick$: m,
42
+ disabled: o || a.value,
43
+ class: `flowsta-login-button ${d || t.class || ""}`,
44
44
  "aria-label": "Sign in with Flowsta",
45
45
  style: {
46
46
  border: "none",
47
47
  background: "transparent",
48
48
  padding: "0",
49
- cursor: t || a.value ? "not-allowed" : "pointer",
50
- opacity: t || a.value ? "0.6" : "1",
49
+ cursor: o || a.value ? "not-allowed" : "pointer",
50
+ opacity: o || a.value ? "0.6" : "1",
51
51
  transition: "opacity 0.2s ease"
52
52
  },
53
53
  children: /* @__PURE__ */ n(
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @flowsta/login-button/react
3
+ *
4
+ * React components for Flowsta login
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export { FlowstaLoginButton, default } from './FlowstaLoginButton.js';
9
+ export type { FlowstaLoginButtonProps } from './types.js';
10
+ export * from './utils/oauth.js';
11
+ export * from './types.js';
12
+ //# sourceMappingURL=react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACtE,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAG1D,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as u } from "react/jsx-runtime";
2
2
  import { useState as b, useCallback as y } from "react";
3
- import { b as k } from "./oauth-DEOZXwxb.js";
4
- import { h as j, p as A } from "./oauth-DEOZXwxb.js";
3
+ import { b as k } from "./oauth-DieOmaFh.js";
4
+ import { h as j, p as A } from "./oauth-DieOmaFh.js";
5
5
  import { getButtonUrl as x } from "./index.js";
6
6
  function z({
7
7
  clientId: r,
@@ -0,0 +1,100 @@
1
+ /**
2
+ * TypeScript types for Flowsta Login Button
3
+ */
4
+ /**
5
+ * Available button variants
6
+ */
7
+ export type ButtonVariant = 'dark-pill' | 'dark-rectangle' | 'light-pill' | 'light-rectangle' | 'neutral-pill' | 'neutral-rectangle';
8
+ /**
9
+ * OAuth scopes for Flowsta (granular)
10
+ * - openid: User ID (sub) - auto-included
11
+ * - email: Email address and verification status
12
+ * - display_name: User's display name
13
+ * - username: User's @username
14
+ * - did: W3C Decentralized Identifier
15
+ * - public_key: Holochain agent public key
16
+ * - profile_picture: User's profile picture
17
+ */
18
+ export type FlowstaScope = 'openid' | 'email' | 'display_name' | 'username' | 'did' | 'public_key' | 'profile_picture' | 'holochain';
19
+ /**
20
+ * Configuration for the Flowsta login button
21
+ */
22
+ export interface FlowstaLoginConfig {
23
+ /** Your Flowsta application client ID (required) */
24
+ clientId: string;
25
+ /** The URI to redirect back to after authentication (required) */
26
+ redirectUri: string;
27
+ /** OAuth scopes to request (default: ['openid', 'email', 'display_name']) */
28
+ scopes?: FlowstaScope[];
29
+ /** Button visual variant (default: 'dark-pill') */
30
+ variant?: ButtonVariant;
31
+ /** The Flowsta login URL (default: https://login.flowsta.com) */
32
+ loginUrl?: string;
33
+ /** Custom CSS class name for the button */
34
+ className?: string;
35
+ /** Whether the button is disabled */
36
+ disabled?: boolean;
37
+ }
38
+ /**
39
+ * Callback data after successful authentication
40
+ */
41
+ export interface FlowstaLoginSuccess {
42
+ /** Authorization code to exchange for access token */
43
+ code: string;
44
+ /** State parameter for validation */
45
+ state: string;
46
+ }
47
+ /**
48
+ * Error data after failed authentication
49
+ */
50
+ export interface FlowstaLoginError {
51
+ /** Error code */
52
+ error: string;
53
+ /** Human-readable error description */
54
+ errorDescription?: string;
55
+ }
56
+ /**
57
+ * Props for React component
58
+ */
59
+ export interface FlowstaLoginButtonProps extends FlowstaLoginConfig {
60
+ /** Callback when login succeeds */
61
+ onSuccess?: (data: FlowstaLoginSuccess) => void;
62
+ /** Callback when login fails */
63
+ onError?: (error: FlowstaLoginError) => void;
64
+ /** Callback when button is clicked (before redirect) */
65
+ onClick?: () => void;
66
+ /** Custom button content (overrides default image) */
67
+ children?: React.ReactNode;
68
+ }
69
+ /**
70
+ * Props for Vue component
71
+ */
72
+ export interface VueFlowstaLoginButtonProps extends FlowstaLoginConfig {
73
+ /** Custom button content (overrides default image) */
74
+ customContent?: string;
75
+ }
76
+ /**
77
+ * Events for Vue component
78
+ */
79
+ export interface VueFlowstaLoginButtonEvents {
80
+ /** Emitted when login succeeds */
81
+ success: (data: FlowstaLoginSuccess) => void;
82
+ /** Emitted when login fails */
83
+ error: (error: FlowstaLoginError) => void;
84
+ /** Emitted when button is clicked (before redirect) */
85
+ click: () => void;
86
+ }
87
+ /**
88
+ * Props for Qwik component
89
+ */
90
+ export interface FlowstaLoginButtonQwikProps extends FlowstaLoginConfig {
91
+ /** Callback when login succeeds (Qwik QRL) */
92
+ onSuccess$?: (data: FlowstaLoginSuccess) => void;
93
+ /** Callback when login fails (Qwik QRL) */
94
+ onError$?: (error: FlowstaLoginError) => void;
95
+ /** Callback when button is clicked (before redirect, Qwik QRL) */
96
+ onClick$?: () => void;
97
+ /** Custom CSS class name */
98
+ class?: string;
99
+ }
100
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,gBAAgB,GAChB,YAAY,GACZ,iBAAiB,GACjB,cAAc,GACd,mBAAmB,CAAC;AAExB;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,OAAO,GACP,cAAc,GACd,UAAU,GACV,KAAK,GACL,YAAY,GACZ,iBAAiB,GACjB,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IAEjB,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAC;IAEpB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IAExB,mDAAmD;IACnD,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IAEb,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IAEd,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,mCAAmC;IACnC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAEhD,gCAAgC;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAE7C,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,kCAAkC;IAClC,OAAO,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAE7C,+BAA+B;IAC/B,KAAK,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAE1C,uDAAuD;IACvD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,kBAAkB;IACrE,8CAA8C;IAC9C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAEjD,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAE9C,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAEtB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * OAuth 2.0 utilities for Flowsta authentication
3
+ */
4
+ export interface OAuthConfig {
5
+ /** Your Flowsta application client ID */
6
+ clientId: string;
7
+ /** The URI to redirect back to after authentication */
8
+ redirectUri: string;
9
+ /** OAuth scopes to request (e.g., ['openid', 'email', 'display_name']) */
10
+ scopes: string[];
11
+ /** The Flowsta login URL (default: https://login.flowsta.com) */
12
+ loginUrl?: string;
13
+ }
14
+ export interface AuthorizationUrlResult {
15
+ /** The complete authorization URL to redirect to */
16
+ url: string;
17
+ /** The state parameter (for validation) */
18
+ state: string;
19
+ /** The code verifier (store securely for token exchange) */
20
+ codeVerifier: string;
21
+ }
22
+ /**
23
+ * Build the OAuth authorization URL with PKCE
24
+ * @param config - OAuth configuration
25
+ * @returns Promise resolving to authorization URL and PKCE parameters
26
+ */
27
+ export declare function buildAuthorizationUrl(config: OAuthConfig): Promise<AuthorizationUrlResult>;
28
+ /**
29
+ * Parse the OAuth callback URL for authorization code and state
30
+ * @param callbackUrl - The full callback URL (or search string)
31
+ * @returns Object with code, state, and any error
32
+ */
33
+ export declare function parseCallbackUrl(callbackUrl: string): {
34
+ code?: string;
35
+ state?: string;
36
+ error?: string;
37
+ errorDescription?: string;
38
+ };
39
+ /**
40
+ * Handle the OAuth callback after user authentication
41
+ * This should be called on your redirect URI page
42
+ * @returns Object with authorization code or error
43
+ */
44
+ export declare function handleCallback(): {
45
+ code?: string;
46
+ state?: string;
47
+ error?: string;
48
+ errorDescription?: string;
49
+ };
50
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/utils/oauth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,sBAAsB,CAAC,CA+BjC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAUA;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAEA"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * PKCE (Proof Key for Code Exchange) utilities for OAuth 2.0
3
+ * RFC 7636: https://tools.ietf.org/html/rfc7636
4
+ */
5
+ /**
6
+ * Generate a random code verifier string
7
+ * Must be 43-128 characters long, using [A-Z][a-z][0-9]-._~
8
+ */
9
+ export declare function generateCodeVerifier(): string;
10
+ /**
11
+ * Generate a code challenge from a code verifier using SHA-256
12
+ * @param verifier - The code verifier string
13
+ * @returns Promise that resolves to the code challenge
14
+ */
15
+ export declare function generateCodeChallenge(verifier: string): Promise<string>;
16
+ /**
17
+ * Generate a PKCE pair (verifier and challenge)
18
+ * @returns Promise that resolves to { verifier, challenge }
19
+ */
20
+ export declare function generatePKCEPair(): Promise<{
21
+ verifier: string;
22
+ challenge: string;
23
+ }>;
24
+ /**
25
+ * Store code verifier in session storage
26
+ * @param verifier - The code verifier to store
27
+ * @param state - The state parameter for correlation
28
+ */
29
+ export declare function storeCodeVerifier(verifier: string, state: string): void;
30
+ /**
31
+ * Retrieve and remove code verifier from session storage
32
+ * @param state - The state parameter for correlation
33
+ * @returns The code verifier or null if not found
34
+ */
35
+ export declare function retrieveCodeVerifier(state: string): string | null;
36
+ //# sourceMappingURL=pkce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../src/utils/pkce.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK7E;AAeD;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,CAID;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMvE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWjE"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * State parameter utilities for OAuth 2.0 CSRF protection
3
+ */
4
+ /**
5
+ * Generate a random state parameter
6
+ * @returns A random base64url encoded string
7
+ */
8
+ export declare function generateState(): string;
9
+ /**
10
+ * Store state in session storage
11
+ * @param state - The state parameter to store
12
+ */
13
+ export declare function storeState(state: string): void;
14
+ /**
15
+ * Retrieve and remove state from session storage
16
+ * @returns The state parameter or null if not found
17
+ */
18
+ export declare function retrieveState(): string | null;
19
+ /**
20
+ * Validate that the returned state matches the stored state
21
+ * @param returnedState - The state returned from OAuth provider
22
+ * @returns true if states match, false otherwise
23
+ */
24
+ export declare function validateState(returnedState: string): boolean;
25
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/utils/state.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAeD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAM9C;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAW7C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAG5D"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @flowsta/login-button/vanilla
3
+ *
4
+ * Vanilla JavaScript implementation for Flowsta login
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export { createFlowstaLoginButton, initFlowstaLoginButton, default } from './FlowstaLoginButtonVanilla.js';
9
+ export type { FlowstaLoginButtonVanillaOptions } from './FlowstaLoginButtonVanilla.js';
10
+ export * from './utils/oauth.js';
11
+ export * from './utils/pkce.js';
12
+ export * from './utils/state.js';
13
+ export * from './types.js';
14
+ //# sourceMappingURL=vanilla.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vanilla.d.ts","sourceRoot":"","sources":["../src/vanilla.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,OAAO,EACR,MAAM,gCAAgC,CAAC;AAExC,YAAY,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAGvF,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
package/dist/vanilla.js CHANGED
@@ -1,15 +1,15 @@
1
- import { b as w } from "./oauth-DEOZXwxb.js";
2
- import { a as S, g as E, c as _, d as F, h as L, p as U, r as V, f as $, s as x, e as B, v as N } from "./oauth-DEOZXwxb.js";
1
+ import { b as w } from "./oauth-DieOmaFh.js";
2
+ import { g as S, a as E, c as _, d as F, h as L, p as U, r as V, e as $, s as x, f as B, v as N } from "./oauth-DieOmaFh.js";
3
3
  function c(e) {
4
4
  const {
5
5
  clientId: s,
6
6
  redirectUri: n,
7
- scopes: r = ["profile"],
7
+ scopes: r = ["openid", "email", "display_name"],
8
8
  variant: d = "dark-pill",
9
9
  loginUrl: u,
10
10
  className: g = "",
11
11
  disabled: o = !1,
12
- onSuccess: m,
12
+ onSuccess: h,
13
13
  onError: p,
14
14
  onClick: f
15
15
  } = e, t = document.createElement("button");
@@ -49,7 +49,7 @@ function c(e) {
49
49
  }
50
50
  }), t;
51
51
  }
52
- function h(e, s) {
52
+ function m(e, s) {
53
53
  const n = typeof e == "string" ? document.querySelector(e) : e;
54
54
  if (!n)
55
55
  throw new Error(`Container not found: ${e}`);
@@ -58,7 +58,7 @@ function h(e, s) {
58
58
  }
59
59
  const C = {
60
60
  createFlowstaLoginButton: c,
61
- initFlowstaLoginButton: h
61
+ initFlowstaLoginButton: m
62
62
  };
63
63
  export {
64
64
  w as buildAuthorizationUrl,
@@ -69,7 +69,7 @@ export {
69
69
  _ as generatePKCEPair,
70
70
  F as generateState,
71
71
  L as handleCallback,
72
- h as initFlowstaLoginButton,
72
+ m as initFlowstaLoginButton,
73
73
  U as parseCallbackUrl,
74
74
  V as retrieveCodeVerifier,
75
75
  $ as retrieveState,
package/dist/vue.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @flowsta/login-button/vue
3
+ *
4
+ * Vue 3 components for Flowsta login
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export { default as FlowstaLoginButton } from './FlowstaLoginButtonVue.vue';
9
+ export type { VueFlowstaLoginButtonProps, VueFlowstaLoginButtonEvents } from './types.js';
10
+ export * from './utils/oauth.js';
11
+ export * from './types.js';
12
+ //# sourceMappingURL=vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vue.d.ts","sourceRoot":"","sources":["../src/vue.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,YAAY,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAG1F,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
package/dist/vue.js CHANGED
@@ -1,21 +1,21 @@
1
- import { defineComponent as u, ref as m, computed as s, createElementBlock as p, openBlock as g, normalizeStyle as f, normalizeClass as b, renderSlot as h, createElementVNode as w } from "vue";
2
- import { b as _ } from "./oauth-DEOZXwxb.js";
3
- import { h as z, p as I } from "./oauth-DEOZXwxb.js";
4
- const v = ["disabled"], k = ["src"], y = /* @__PURE__ */ u({
1
+ import { defineComponent as u, ref as m, computed as s, openBlock as p, createElementBlock as g, normalizeStyle as f, normalizeClass as b, renderSlot as h, createElementVNode as _ } from "vue";
2
+ import { b as w } from "./oauth-DieOmaFh.js";
3
+ import { h as z, p as I } from "./oauth-DieOmaFh.js";
4
+ const v = ["disabled"], y = ["src"], k = /* @__PURE__ */ u({
5
5
  __name: "FlowstaLoginButtonVue",
6
6
  props: {
7
7
  customContent: {},
8
8
  clientId: {},
9
9
  redirectUri: {},
10
- scopes: { default: () => ["profile"] },
10
+ scopes: { default: () => ["openid", "email", "display_name"] },
11
11
  variant: { default: "dark-pill" },
12
12
  loginUrl: {},
13
13
  className: { default: "" },
14
14
  disabled: { type: Boolean, default: !1 }
15
15
  },
16
16
  emits: ["success", "error", "click"],
17
- setup(a, { emit: n }) {
18
- const e = a, l = n, t = m(!1), r = s(() => `/node_modules/@flowsta/login-button/assets/svg/${`flowsta_signin_web_${e.variant.replace("-", "_")}`}.svg`), i = s(() => ({
17
+ setup(o, { emit: n }) {
18
+ const e = o, l = n, t = m(!1), r = s(() => `/node_modules/@flowsta/login-button/assets/svg/${`flowsta_signin_web_${e.variant.replace("-", "_")}`}.svg`), i = s(() => ({
19
19
  border: "none",
20
20
  background: "transparent",
21
21
  padding: 0,
@@ -31,49 +31,49 @@ const v = ["disabled"], k = ["src"], y = /* @__PURE__ */ u({
31
31
  t.value = !0;
32
32
  try {
33
33
  l("click");
34
- const { url: o } = await _({
34
+ const { url: a } = await w({
35
35
  clientId: e.clientId,
36
36
  redirectUri: e.redirectUri,
37
37
  scopes: e.scopes,
38
38
  loginUrl: e.loginUrl
39
39
  });
40
- window.location.href = o;
41
- } catch (o) {
40
+ window.location.href = a;
41
+ } catch (a) {
42
42
  t.value = !1, l("error", {
43
43
  error: "authorization_failed",
44
- errorDescription: o instanceof Error ? o.message : "Unknown error"
44
+ errorDescription: a instanceof Error ? a.message : "Unknown error"
45
45
  });
46
46
  }
47
47
  }
48
48
  };
49
- return (o, C) => (g(), p("button", {
49
+ return (a, C) => (p(), g("button", {
50
50
  type: "button",
51
- class: b(["flowsta-login-button", a.className]),
52
- disabled: a.disabled || t.value,
51
+ class: b(["flowsta-login-button", o.className]),
52
+ disabled: o.disabled || t.value,
53
53
  "aria-label": "Sign in with Flowsta",
54
54
  style: f(i.value),
55
55
  onClick: d
56
56
  }, [
57
- h(o.$slots, "default", {}, () => [
58
- w("img", {
57
+ h(a.$slots, "default", {}, () => [
58
+ _("img", {
59
59
  src: r.value,
60
60
  alt: "Sign in with Flowsta",
61
61
  width: "175",
62
62
  height: "40",
63
63
  style: c
64
- }, null, 8, k)
64
+ }, null, 8, y)
65
65
  ], !0)
66
66
  ], 14, v));
67
67
  }
68
- }), U = (a, n) => {
69
- const e = a.__vccOpts || a;
68
+ }), U = (o, n) => {
69
+ const e = o.__vccOpts || o;
70
70
  for (const [l, t] of n)
71
71
  e[l] = t;
72
72
  return e;
73
- }, F = /* @__PURE__ */ U(y, [["__scopeId", "data-v-9a637830"]]);
73
+ }, F = /* @__PURE__ */ U(k, [["__scopeId", "data-v-a5deb683"]]);
74
74
  export {
75
75
  F as FlowstaLoginButton,
76
- _ as buildAuthorizationUrl,
76
+ w as buildAuthorizationUrl,
77
77
  z as handleCallback,
78
78
  I as parseCallbackUrl
79
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowsta/login-button",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Login with Flowsta button components for React, Vue, Qwik, and vanilla JavaScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "scripts": {
36
36
  "dev": "vite build --watch",
37
- "build": "tsc && vite build",
37
+ "build": "vite build && tsc",
38
38
  "test": "echo 'Tests not yet implemented'",
39
39
  "prepublishOnly": "npm run build"
40
40
  },
@@ -77,6 +77,7 @@
77
77
  "@builder.io/qwik": "^1.9.0",
78
78
  "@types/react": "^18.3.3",
79
79
  "@vitejs/plugin-vue": "^6.0.1",
80
+ "happy-dom": "20.5.0",
80
81
  "react": "^18.3.1",
81
82
  "typescript": "^5.5.4",
82
83
  "vite": "^7.3.1",
@@ -84,8 +85,5 @@
84
85
  },
85
86
  "engines": {
86
87
  "node": ">=18.0.0"
87
- },
88
- "dependencies": {
89
- "happy-dom": "20.5.0"
90
88
  }
91
89
  }