syntro-js-client 1.0.0 → 1.0.2

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/index.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ export declare class Syntro {
2
+ constructor(apiKey: string);
3
+
4
+ /** JWT token obtained after login */
5
+ readonly _token: string | null;
6
+
7
+ /** Log in with email and password. Stores the JWT token internally. */
8
+ login(email: string, password: string): Promise<{
9
+ accessToken: string;
10
+ [key: string]: unknown;
11
+ }>;
12
+
13
+ /** Register a new user. */
14
+ register(
15
+ email: string,
16
+ password: string,
17
+ extra?: Record<string, unknown>
18
+ ): Promise<unknown>;
19
+
20
+ /**
21
+ * Returns a redirect URL for social OAuth login.
22
+ * @param provider - 'google' | 'github'
23
+ */
24
+ socialLogin(provider: 'google' | 'github'): Promise<{ redirectUrl: string }>;
25
+
26
+ /** Send a forgot-password email. */
27
+ forgotPassword(email: string): Promise<unknown>;
28
+
29
+ /** Reset password using a token from the forgot-password email. */
30
+ resetPassword(token: string, password: string): Promise<unknown>;
31
+
32
+ /** Fetch the currently authenticated user (requires prior login). */
33
+ me(): Promise<unknown>;
34
+
35
+ /**
36
+ * Create a billing / payment session.
37
+ * @param name - Product / plan name
38
+ * @param description - Short description shown to the customer
39
+ * @param amount - Amount in the smallest currency unit (e.g. cents)
40
+ * @param methods - Payment methods to accept, default ['card']
41
+ * @param options - Extra options: currency, successUrl, cancelUrl
42
+ */
43
+ createBilling(
44
+ name: string,
45
+ description: string,
46
+ amount: number,
47
+ methods?: string[],
48
+ options?: {
49
+ currency?: string;
50
+ successUrl?: string;
51
+ cancelUrl?: string;
52
+ }
53
+ ): Promise<unknown>;
54
+
55
+ /** Track a custom analytics event. */
56
+ trackEvent(type: string, payload?: Record<string, unknown>): Promise<unknown>;
57
+
58
+ /** Retrieve tracked events, optionally filtered by query params. */
59
+ getEvents(params?: Record<string, string>): Promise<unknown>;
60
+
61
+ /** Get aggregated stats for the current project. */
62
+ getStats(): Promise<unknown>;
63
+
64
+ /** Update / increment a specific stat metric. */
65
+ updateStat(metric: string, value: number): Promise<unknown>;
66
+ }
67
+
68
+ export default Syntro;
package/index.js CHANGED
@@ -96,4 +96,6 @@ class Syntro {
96
96
  }
97
97
  }
98
98
 
99
- module.exports = { Syntro };
99
+ // Support both: import { Syntro } from '...' AND import Syntro from '...'
100
+ module.exports = Syntro;
101
+ module.exports.Syntro = Syntro;
package/package.json CHANGED
@@ -1,8 +1,19 @@
1
1
  {
2
2
  "name": "syntro-js-client",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Official Node.js SDK for Syntro — plug-and-play auth, billing, and analytics for your SaaS.",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./index.js",
10
+ "types": "./index.d.ts"
11
+ },
12
+ "./react": {
13
+ "require": "./react.js",
14
+ "types": "./react.d.ts"
15
+ }
16
+ },
6
17
  "keywords": [
7
18
  "syntro",
8
19
  "auth",
@@ -18,4 +29,4 @@
18
29
  "peerDependencies": {
19
30
  "react": ">=16.8.0"
20
31
  }
21
- }
32
+ }
package/react.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import * as React from 'react';
2
+ import { Syntro } from './index';
3
+
4
+ // ─── Context value shape ──────────────────────────────────────────────────────
5
+
6
+ export interface SyntroContextValue {
7
+ client: Syntro | null;
8
+ user: unknown | null;
9
+ loading: boolean;
10
+ }
11
+
12
+ // ─── SyntroProvider ───────────────────────────────────────────────────────────
13
+
14
+ export interface SyntroProviderProps {
15
+ client: Syntro;
16
+ children?: React.ReactNode;
17
+ }
18
+
19
+ export declare const SyntroProvider: React.FC<SyntroProviderProps>;
20
+
21
+ // ─── useSyntro ────────────────────────────────────────────────────────────────
22
+
23
+ export declare function useSyntro(): SyntroContextValue;
24
+
25
+ // ─── SyntroProtected ─────────────────────────────────────────────────────────
26
+
27
+ export interface SyntroProtectedProps {
28
+ /** Content to render when the user is not authenticated */
29
+ fallback?: React.ReactNode;
30
+ /** If provided, redirects unauthenticated users to this URL */
31
+ redirectTo?: string;
32
+ children?: React.ReactNode;
33
+ }
34
+
35
+ export declare const SyntroProtected: React.FC<SyntroProtectedProps>;