@beamarco/auth-sdk 0.1.2 → 0.1.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/components/SignIn.d.ts.map +1 -1
- package/dist/components/SignIn.js +17 -42
- package/dist/components/SignUp.d.ts.map +1 -1
- package/dist/components/SignUp.js +18 -37
- package/dist/context.d.ts +5 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +4 -7
- package/dist/resolve-config.js +2 -2
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +2 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../src/components/SignIn.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEhD,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDlB,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,oBAAoB;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,aAAa,CAAC,CAAA;IACtC,iCAAiC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sDAAsD;IACtD,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,KAAK,CAAC,SAAS,CAAA;CACzD;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,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AAI,CAAC,CAAA;IACxD,gBAAgB,EAAE,CAAC,UAAU,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,MAAM,CAAC,EACrB,cAAc,EACd,MAAM,EAAE,YAAiB,EACzB,UAAiB,EACjB,SAAsB,EACtB,iBAAiB,EACjB,SAAS,EACT,QAAQ,GACT,EAAE,WAAW,2CAuHb"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { useState } from 'react';
|
|
3
3
|
import { useBeamarAuth } from '../hooks';
|
|
4
4
|
const defaultStyles = {
|
|
5
5
|
container: {
|
|
@@ -59,7 +59,7 @@ const defaultStyles = {
|
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
61
|
export function SignIn({ afterSignInUrl, styles: customStyles = {}, showGoogle = true, signUpUrl = '/sign-up', forgotPasswordUrl, onSuccess, children, }) {
|
|
62
|
-
const { signIn,
|
|
62
|
+
const { signIn, apiUrl, appName } = useBeamarAuth();
|
|
63
63
|
const [email, setEmail] = useState('');
|
|
64
64
|
const [password, setPassword] = useState('');
|
|
65
65
|
const [error, setError] = useState(null);
|
|
@@ -83,22 +83,17 @@ export function SignIn({ afterSignInUrl, styles: customStyles = {}, showGoogle =
|
|
|
83
83
|
setIsLoading(false);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
setError(err instanceof Error ? err.message : 'Sign in with Google failed');
|
|
98
|
-
}
|
|
99
|
-
finally {
|
|
100
|
-
setIsLoading(false);
|
|
101
|
-
}
|
|
86
|
+
const redirectToHostedGoogleSignIn = () => {
|
|
87
|
+
const base = afterSignInUrl ?? '/';
|
|
88
|
+
const redirectUri = typeof window !== 'undefined' && base.startsWith('/')
|
|
89
|
+
? window.location.origin + base
|
|
90
|
+
: base;
|
|
91
|
+
const params = new URLSearchParams({
|
|
92
|
+
redirect_uri: redirectUri,
|
|
93
|
+
app: appName,
|
|
94
|
+
mode: 'signin',
|
|
95
|
+
});
|
|
96
|
+
window.location.href = `${apiUrl.replace(/\/$/, '')}/sign-in?${params}`;
|
|
102
97
|
};
|
|
103
98
|
if (children) {
|
|
104
99
|
return (_jsx(_Fragment, { children: children({
|
|
@@ -119,32 +114,12 @@ export function SignIn({ afterSignInUrl, styles: customStyles = {}, showGoogle =
|
|
|
119
114
|
setIsLoading(false);
|
|
120
115
|
}
|
|
121
116
|
},
|
|
122
|
-
signInWithGoogle:
|
|
117
|
+
signInWithGoogle: async () => {
|
|
118
|
+
redirectToHostedGoogleSignIn();
|
|
119
|
+
},
|
|
123
120
|
error,
|
|
124
121
|
isLoading,
|
|
125
122
|
}) }));
|
|
126
123
|
}
|
|
127
|
-
return (_jsxs("form", { onSubmit: handleSubmit, style: styles.container, children: [error && _jsx("div", { style: styles.error, children: error }), _jsx("input", { type: "email", placeholder: "Email", value: email, onChange: (e) => setEmail(e.target.value), required: true, disabled: isLoading, style: styles.input }), _jsx("input", { type: "password", placeholder: "Password", value: password, onChange: (e) => setPassword(e.target.value), required: true, disabled: isLoading, style: styles.input }), forgotPasswordUrl && (_jsx("a", { href: forgotPasswordUrl, style: styles.link, children: "Forgot password?" })), _jsx("button", { type: "submit", disabled: isLoading, style: styles.button, children: isLoading ? 'Signing in...' : 'Sign in' }), showGoogle && (_jsxs(_Fragment, { children: [_jsxs("div", { style: styles.divider, children: [_jsx("span", { style: styles.dividerLine }), _jsx("span", { children: "or" }), _jsx("span", { style: styles.dividerLine })] }), _jsx(
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Google Sign In button - requires GoogleOAuthProvider wrapper with clientId from config
|
|
131
|
-
*/
|
|
132
|
-
function GoogleSignInButton({ onSuccess, disabled, clientId, }) {
|
|
133
|
-
const [GoogleLogin, setGoogleLogin] = useState(null);
|
|
134
|
-
React.useEffect(() => {
|
|
135
|
-
import('@react-oauth/google').then((mod) => {
|
|
136
|
-
setGoogleLogin(() => mod.GoogleLogin);
|
|
137
|
-
});
|
|
138
|
-
}, []);
|
|
139
|
-
if (!clientId)
|
|
140
|
-
return null;
|
|
141
|
-
if (!GoogleLogin) {
|
|
142
|
-
return (_jsx("button", { type: "button", disabled: true, style: { ...defaultStyles.buttonGoogle, opacity: 0.7 }, children: "Loading..." }));
|
|
143
|
-
}
|
|
144
|
-
const GoogleLoginAny = GoogleLogin;
|
|
145
|
-
return (_jsx(GoogleLoginAny, { onSuccess: (res) => {
|
|
146
|
-
if (res.credential && res.clientId) {
|
|
147
|
-
onSuccess({ credential: res.credential, clientId: res.clientId });
|
|
148
|
-
}
|
|
149
|
-
}, onError: () => { }, useOneTap: false, type: "standard", theme: "outline", size: "large", text: "signin_with", shape: "rectangular", logo_alignment: "left", width: "320" }));
|
|
124
|
+
return (_jsxs("form", { onSubmit: handleSubmit, style: styles.container, children: [error && _jsx("div", { style: styles.error, children: error }), _jsx("input", { type: "email", placeholder: "Email", value: email, onChange: (e) => setEmail(e.target.value), required: true, disabled: isLoading, style: styles.input }), _jsx("input", { type: "password", placeholder: "Password", value: password, onChange: (e) => setPassword(e.target.value), required: true, disabled: isLoading, style: styles.input }), forgotPasswordUrl && (_jsx("a", { href: forgotPasswordUrl, style: styles.link, children: "Forgot password?" })), _jsx("button", { type: "submit", disabled: isLoading, style: styles.button, children: isLoading ? 'Signing in...' : 'Sign in' }), showGoogle && (_jsxs(_Fragment, { children: [_jsxs("div", { style: styles.divider, children: [_jsx("span", { style: styles.dividerLine }), _jsx("span", { children: "or" }), _jsx("span", { style: styles.dividerLine })] }), _jsx("button", { type: "button", onClick: redirectToHostedGoogleSignIn, disabled: isLoading, style: styles.buttonGoogle, children: "Sign in with Google" })] })), _jsxs("p", { children: ["Don't have an account? ", _jsx("a", { href: signUpUrl, style: styles.link, children: "Sign up" })] })] }));
|
|
150
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUp.d.ts","sourceRoot":"","sources":["../../src/components/SignUp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDlB,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,aAAa,CAAC,CAAA;IACtC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,KAAK,CAAC,SAAS,CAAA;CACzD;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,CAAC,WAAW,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3D,gBAAgB,EAAE,CAAC,UAAU,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;CACnB;
|
|
1
|
+
{"version":3,"file":"SignUp.d.ts","sourceRoot":"","sources":["../../src/components/SignUp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDlB,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,aAAa,CAAC,CAAA;IACtC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,KAAK,CAAC,SAAS,CAAA;CACzD;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,CAAC,WAAW,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3D,gBAAgB,EAAE,CAAC,UAAU,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,MAAM,CAAC,EACrB,cAAoB,EACpB,MAAM,EAAE,YAAiB,EACzB,UAAiB,EACjB,SAAsB,EACtB,SAAS,EACT,QAAQ,GACT,EAAE,WAAW,2CAmHb"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
3
|
import { useBeamarAuth } from '../hooks';
|
|
4
4
|
const defaultStyles = {
|
|
5
5
|
container: {
|
|
@@ -58,24 +58,8 @@ const defaultStyles = {
|
|
|
58
58
|
backgroundColor: '#ddd',
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
|
-
function GoogleSignUpButton({ onSuccess, disabled, clientId, }) {
|
|
62
|
-
const [GoogleLogin, setGoogleLogin] = useState(null);
|
|
63
|
-
React.useEffect(() => {
|
|
64
|
-
import('@react-oauth/google').then((mod) => {
|
|
65
|
-
setGoogleLogin(() => mod.GoogleLogin);
|
|
66
|
-
});
|
|
67
|
-
}, []);
|
|
68
|
-
if (!clientId || !GoogleLogin)
|
|
69
|
-
return null;
|
|
70
|
-
const GoogleLoginAny = GoogleLogin;
|
|
71
|
-
return (_jsx(GoogleLoginAny, { onSuccess: (res) => {
|
|
72
|
-
if (res.credential && res.clientId) {
|
|
73
|
-
onSuccess({ credential: res.credential, clientId: res.clientId });
|
|
74
|
-
}
|
|
75
|
-
}, onError: () => { }, type: "standard", theme: "outline", size: "large", text: "signup_with", shape: "rectangular", logo_alignment: "left", width: "320" }));
|
|
76
|
-
}
|
|
77
61
|
export function SignUp({ afterSignUpUrl = '/', styles: customStyles = {}, showGoogle = true, signInUrl = '/sign-in', onSuccess, children, }) {
|
|
78
|
-
const { signUp,
|
|
62
|
+
const { signUp, apiUrl, appName } = useBeamarAuth();
|
|
79
63
|
const [email, setEmail] = useState('');
|
|
80
64
|
const [password, setPassword] = useState('');
|
|
81
65
|
const [error, setError] = useState(null);
|
|
@@ -99,22 +83,17 @@ export function SignUp({ afterSignUpUrl = '/', styles: customStyles = {}, showGo
|
|
|
99
83
|
setIsLoading(false);
|
|
100
84
|
}
|
|
101
85
|
};
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
setError(err instanceof Error ? err.message : 'Sign up with Google failed');
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
setIsLoading(false);
|
|
117
|
-
}
|
|
86
|
+
const redirectToHostedGoogleSignUp = () => {
|
|
87
|
+
const base = afterSignUpUrl ?? '/';
|
|
88
|
+
const redirectUri = typeof window !== 'undefined' && base.startsWith('/')
|
|
89
|
+
? window.location.origin + base
|
|
90
|
+
: base;
|
|
91
|
+
const params = new URLSearchParams({
|
|
92
|
+
redirect_uri: redirectUri,
|
|
93
|
+
app: appName,
|
|
94
|
+
mode: 'signup',
|
|
95
|
+
});
|
|
96
|
+
window.location.href = `${apiUrl.replace(/\/$/, '')}/sign-in?${params}`;
|
|
118
97
|
};
|
|
119
98
|
if (children) {
|
|
120
99
|
return (_jsx(_Fragment, { children: children({
|
|
@@ -135,10 +114,12 @@ export function SignUp({ afterSignUpUrl = '/', styles: customStyles = {}, showGo
|
|
|
135
114
|
setIsLoading(false);
|
|
136
115
|
}
|
|
137
116
|
},
|
|
138
|
-
signUpWithGoogle:
|
|
117
|
+
signUpWithGoogle: async () => {
|
|
118
|
+
redirectToHostedGoogleSignUp();
|
|
119
|
+
},
|
|
139
120
|
error,
|
|
140
121
|
isLoading,
|
|
141
122
|
}) }));
|
|
142
123
|
}
|
|
143
|
-
return (_jsxs("form", { onSubmit: handleSubmit, style: styles.container, children: [error && _jsx("div", { style: styles.error, children: error }), _jsx("input", { type: "email", placeholder: "Email", value: email, onChange: (e) => setEmail(e.target.value), required: true, disabled: isLoading, style: styles.input }), _jsx("input", { type: "password", placeholder: "Password", value: password, onChange: (e) => setPassword(e.target.value), required: true, disabled: isLoading, minLength: 6, style: styles.input }), _jsx("button", { type: "submit", disabled: isLoading, style: styles.button, children: isLoading ? 'Creating account...' : 'Sign up' }), showGoogle && (_jsxs(_Fragment, { children: [_jsxs("div", { style: styles.divider, children: [_jsx("span", { style: styles.dividerLine }), _jsx("span", { children: "or" }), _jsx("span", { style: styles.dividerLine })] }), _jsx(
|
|
124
|
+
return (_jsxs("form", { onSubmit: handleSubmit, style: styles.container, children: [error && _jsx("div", { style: styles.error, children: error }), _jsx("input", { type: "email", placeholder: "Email", value: email, onChange: (e) => setEmail(e.target.value), required: true, disabled: isLoading, style: styles.input }), _jsx("input", { type: "password", placeholder: "Password", value: password, onChange: (e) => setPassword(e.target.value), required: true, disabled: isLoading, minLength: 6, style: styles.input }), _jsx("button", { type: "submit", disabled: isLoading, style: styles.button, children: isLoading ? 'Creating account...' : 'Sign up' }), showGoogle && (_jsxs(_Fragment, { children: [_jsxs("div", { style: styles.divider, children: [_jsx("span", { style: styles.dividerLine }), _jsx("span", { children: "or" }), _jsx("span", { style: styles.dividerLine })] }), _jsx("button", { type: "button", onClick: redirectToHostedGoogleSignUp, disabled: isLoading, style: styles.buttonGoogle, children: "Sign up with Google" })] })), _jsxs("p", { children: ["Already have an account? ", _jsx("a", { href: signInUrl, style: styles.link, children: "Sign in" })] })] }));
|
|
144
125
|
}
|
package/dist/context.d.ts
CHANGED
|
@@ -13,7 +13,11 @@ export interface AuthContextValue {
|
|
|
13
13
|
getToken: () => Promise<string | null>;
|
|
14
14
|
refreshSession: () => Promise<User | null>;
|
|
15
15
|
client: BeamarAuthClient;
|
|
16
|
-
/**
|
|
16
|
+
/** Auth API base URL (for redirect flow) */
|
|
17
|
+
apiUrl: string;
|
|
18
|
+
/** App name (for redirect flow) */
|
|
19
|
+
appName: string;
|
|
20
|
+
/** Google OAuth client ID - only used when googleSignInFlow is 'inline' */
|
|
17
21
|
googleClientId?: string;
|
|
18
22
|
}
|
|
19
23
|
declare const AuthContext: React.Context<AuthContextValue | null>;
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0D,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0D,MAAM,OAAO,CAAA;AAC9E,OAAO,EAAE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AAC,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,uBAAuB,2CA6I3G;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
package/dist/context.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React, { createContext, useCallback, useEffect, useState } from 'react';
|
|
3
|
-
import { GoogleOAuthProvider } from '@react-oauth/google';
|
|
4
3
|
import { BeamarAuthClient } from './client';
|
|
5
4
|
import { resolveConfigFromPublishableKey } from './resolve-config';
|
|
6
5
|
const AuthContext = createContext(null);
|
|
@@ -26,7 +25,7 @@ export function BeamarAuthProvider({ config: configProp, publishableKey, childre
|
|
|
26
25
|
.catch((err) => {
|
|
27
26
|
console.error('BeamarAuthProvider: failed to resolve config', err);
|
|
28
27
|
setConfig({
|
|
29
|
-
apiUrl: 'https://auth.beamar.co',
|
|
28
|
+
apiUrl: 'https://auth.s.beamar.co',
|
|
30
29
|
appName: publishableKey,
|
|
31
30
|
});
|
|
32
31
|
});
|
|
@@ -117,6 +116,8 @@ export function BeamarAuthProvider({ config: configProp, publishableKey, childre
|
|
|
117
116
|
getToken,
|
|
118
117
|
refreshSession,
|
|
119
118
|
client: client,
|
|
119
|
+
apiUrl: config?.apiUrl ?? '',
|
|
120
|
+
appName: config?.appName ?? 'default',
|
|
120
121
|
googleClientId: config?.googleClientId,
|
|
121
122
|
};
|
|
122
123
|
if (!config || !client) {
|
|
@@ -125,10 +126,6 @@ export function BeamarAuthProvider({ config: configProp, publishableKey, childre
|
|
|
125
126
|
: 'Loading...';
|
|
126
127
|
return (_jsx("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', minHeight: '100vh' }, children: _jsx("span", { children: msg }) }));
|
|
127
128
|
}
|
|
128
|
-
|
|
129
|
-
if (config.googleClientId) {
|
|
130
|
-
return (_jsx(GoogleOAuthProvider, { clientId: config.googleClientId, children: content }));
|
|
131
|
-
}
|
|
132
|
-
return content;
|
|
129
|
+
return _jsx(AuthContext.Provider, { value: value, children: children });
|
|
133
130
|
}
|
|
134
131
|
export { AuthContext };
|
package/dist/resolve-config.js
CHANGED
|
@@ -24,12 +24,12 @@ function getApiUrl(publishableKey) {
|
|
|
24
24
|
return envUrl;
|
|
25
25
|
const prefix = publishableKey.split('_')[0];
|
|
26
26
|
if (publishableKey.startsWith('beamar_live_') || publishableKey.startsWith('pk_live_')) {
|
|
27
|
-
return 'https://auth.beamar.co';
|
|
27
|
+
return 'https://auth.s.beamar.co';
|
|
28
28
|
}
|
|
29
29
|
if (publishableKey.startsWith('beamar_test_') || publishableKey.startsWith('pk_test_')) {
|
|
30
30
|
return getEnv('VITE_AUTH_API_URL') ?? 'http://localhost:3000';
|
|
31
31
|
}
|
|
32
|
-
return 'https://auth.beamar.co';
|
|
32
|
+
return 'https://auth.s.beamar.co';
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Extract appName from publishableKey
|
package/dist/types.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface TenantMember {
|
|
|
23
23
|
* Configuration for BeamarAuthProvider
|
|
24
24
|
*/
|
|
25
25
|
export interface BeamarAuthConfig {
|
|
26
|
-
/** Base URL of the auth-service API (e.g. https://auth.beamar.co) */
|
|
26
|
+
/** Base URL of the auth-service API (e.g. https://auth.s.beamar.co) */
|
|
27
27
|
apiUrl: string;
|
|
28
28
|
/** Application name for multi-tenant (e.g. GOMEDI, developers-portal) */
|
|
29
29
|
appName: string;
|
|
@@ -33,7 +33,7 @@ export interface BeamarAuthConfig {
|
|
|
33
33
|
parentUrl?: string;
|
|
34
34
|
}
|
|
35
35
|
/** Default auth API URL - overridable via VITE_AUTH_API_URL */
|
|
36
|
-
export declare const DEFAULT_AUTH_API_URL = "https://auth.beamar.co";
|
|
36
|
+
export declare const DEFAULT_AUTH_API_URL = "https://auth.s.beamar.co";
|
|
37
37
|
/** Public config returned by auth-service for frontends */
|
|
38
38
|
export interface BeamarPublicConfig {
|
|
39
39
|
googleClientId?: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAA;IACd,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAA;IACf,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,6BAA6B,CAAA;AAE9D,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,qBAAa,SAAU,SAAQ,KAAK;IAGzB,UAAU,CAAC,EAAE,MAAM;IACnB,IAAI,CAAC,EAAE,MAAM;gBAFpB,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB"}
|
package/dist/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Default auth API URL - overridable via VITE_AUTH_API_URL */
|
|
2
|
-
export const DEFAULT_AUTH_API_URL = 'https://auth.beamar.co';
|
|
2
|
+
export const DEFAULT_AUTH_API_URL = 'https://auth.s.beamar.co';
|
|
3
3
|
export class AuthError extends Error {
|
|
4
4
|
constructor(message, statusCode, code) {
|
|
5
5
|
super(message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beamarco/auth-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Beamar Auth SDK - Embed authentication like Clerk in your React apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,9 +25,7 @@
|
|
|
25
25
|
"react": ">=17.0.0",
|
|
26
26
|
"react-dom": ">=17.0.0"
|
|
27
27
|
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@react-oauth/google": "^0.11.1"
|
|
30
|
-
},
|
|
28
|
+
"dependencies": {},
|
|
31
29
|
"devDependencies": {
|
|
32
30
|
"@types/react": "^18.2.0",
|
|
33
31
|
"react": "^18.2.0",
|