@anujyadav070/frontier-sdk 1.0.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.
package/README.md ADDED
@@ -0,0 +1,168 @@
1
+ # Frontier Auth SDK
2
+
3
+ A lightweight TypeScript SDK for authentication with your Frontier backend application. Currently supports user registration and login functionality.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install frontier-auth-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import FrontierAuth from 'frontier-auth-sdk';
15
+
16
+ const auth = new FrontierAuth();
17
+
18
+ auth
19
+ .setEndpoint('https://your-backend.com/v1')
20
+ .setProject('your-project-id');
21
+
22
+ // Sign up new user
23
+ const user = await auth.account.create('unique-id', 'user@example.com', 'password', 'John Doe');
24
+
25
+ // Login user
26
+ const session = await auth.account.createEmailSession('user@example.com', 'password');
27
+ ```
28
+
29
+ ## Current Features
30
+
31
+ - ✅ User registration (Sign up)
32
+ - ✅ Email/password authentication (Login)
33
+ - ✅ TypeScript support
34
+ - ✅ HTTP client with automatic error handling
35
+ - ✅ Configurable endpoint and project settings
36
+
37
+ ## API Reference
38
+
39
+ ### Client Configuration
40
+
41
+ ```typescript
42
+ const auth = new FrontierAuth();
43
+
44
+ // Set your backend endpoint
45
+ auth.setEndpoint('https://your-backend.com/v1');
46
+
47
+ // Set project ID
48
+ auth.setProject('your-project-id');
49
+
50
+ // Set API key (for server-side usage)
51
+ auth.setKey('your-api-key');
52
+
53
+ // Set JWT token (for authenticated requests)
54
+ auth.setJWT('your-jwt-token');
55
+ ```
56
+
57
+ ### Authentication Methods
58
+
59
+ #### Sign Up
60
+
61
+ Create a new user account:
62
+
63
+ ```typescript
64
+ const user = await auth.account.create(
65
+ 'unique-user-id', // User ID (must be unique)
66
+ 'user@example.com', // Email address
67
+ 'securePassword', // Password
68
+ 'John Doe' // Name (optional)
69
+ );
70
+
71
+ console.log(user);
72
+ // Returns User object with: $id, $createdAt, $updatedAt, name, email, emailVerification, status
73
+ ```
74
+
75
+ #### Login
76
+
77
+ Authenticate user with email and password:
78
+
79
+ ```typescript
80
+ const session = await auth.account.createEmailSession(
81
+ 'user@example.com', // Email address
82
+ 'securePassword' // Password
83
+ );
84
+
85
+ console.log(session);
86
+ // Returns Session object with: $id, userId, expire, provider, ip, device info, etc.
87
+ ```
88
+
89
+
90
+
91
+ ## Error Handling
92
+
93
+ ```typescript
94
+ import { FrontierException, AuthException } from 'frontier-auth-sdk';
95
+
96
+ try {
97
+ await auth.account.createEmailSession('user@example.com', 'wrong-password');
98
+ } catch (error) {
99
+ if (error instanceof AuthException) {
100
+ console.log('Authentication failed:', error.message);
101
+ } else {
102
+ console.log('Error:', error.message);
103
+ }
104
+ }
105
+ ```
106
+
107
+ ## Complete Example
108
+
109
+ ```typescript
110
+ import FrontierAuth from 'frontier-auth-sdk';
111
+
112
+ async function main() {
113
+ // Initialize SDK
114
+ const auth = new FrontierAuth();
115
+
116
+ // Configure
117
+ auth
118
+ .setEndpoint('https://your-backend.com/v1')
119
+ .setProject('your-project-id');
120
+
121
+ try {
122
+ // Sign up new user
123
+ console.log('Creating account...');
124
+ const user = await auth.account.create(
125
+ 'user-123',
126
+ 'john@example.com',
127
+ 'securePassword123',
128
+ 'John Doe'
129
+ );
130
+ console.log('User created:', user);
131
+
132
+ // Login user
133
+ console.log('Logging in...');
134
+ const session = await auth.account.createEmailSession(
135
+ 'john@example.com',
136
+ 'securePassword123'
137
+ );
138
+ console.log('Login successful:', session);
139
+
140
+ } catch (error) {
141
+ console.error('Error:', error.message);
142
+ }
143
+ }
144
+
145
+ ```
146
+
147
+
148
+
149
+ ## Development
150
+
151
+ ```bash
152
+ # Install dependencies
153
+ npm install
154
+
155
+ # Build the SDK
156
+ npm run build
157
+
158
+ # Watch for changes during development
159
+ npm run dev
160
+ ```
161
+
162
+ ## License
163
+
164
+ ISC
165
+
166
+ ## Contributing
167
+
168
+ This SDK is currently in development. More authentication features will be added in future versions.
@@ -0,0 +1,44 @@
1
+ /**
2
+ * HTTP Client for API communication
3
+ */
4
+ export interface ClientConfig {
5
+ endpoint?: string;
6
+ project?: string;
7
+ key?: string;
8
+ jwt?: string;
9
+ locale?: string;
10
+ }
11
+ export declare class Client {
12
+ private config;
13
+ private headers;
14
+ constructor(config?: ClientConfig);
15
+ /**
16
+ * Set API endpoint
17
+ */
18
+ setEndpoint(endpoint: string): Client;
19
+ /**
20
+ * Set project ID
21
+ */
22
+ setProject(project: string): Client;
23
+ /**
24
+ * Set API key
25
+ */
26
+ setKey(key: string): Client;
27
+ /**
28
+ * Set JWT token
29
+ */
30
+ setJWT(jwt: string): Client;
31
+ /**
32
+ * Set locale
33
+ */
34
+ setLocale(locale: string): Client;
35
+ /**
36
+ * Add custom header
37
+ */
38
+ addHeader(key: string, value: string): Client;
39
+ /**
40
+ * Make HTTP request
41
+ */
42
+ call(method: string, path?: string, headers?: Record<string, string>, params?: Record<string, any>): Promise<any>;
43
+ }
44
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,OAAO,CAMb;gBAEU,MAAM,GAAE,YAAiB;IASrC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAKrC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAMnC;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAM3B;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAM3B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAKjC;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAK7C;;OAEG;IACG,IAAI,CACR,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAW,EACjB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACpC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAC/B,OAAO,CAAC,GAAG,CAAC;CAqChB"}
package/dist/client.js ADDED
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ /**
3
+ * HTTP Client for API communication
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Client = void 0;
7
+ class Client {
8
+ constructor(config = {}) {
9
+ this.config = {};
10
+ this.headers = {
11
+ 'content-type': 'application/json',
12
+ 'x-sdk-name': 'Frontier',
13
+ 'x-sdk-platform': 'client',
14
+ 'x-sdk-language': 'typescript',
15
+ 'x-sdk-version': '1.0.0',
16
+ };
17
+ this.config = config;
18
+ this.setEndpoint(config.endpoint || '');
19
+ this.setProject(config.project || '');
20
+ this.setKey(config.key || '');
21
+ this.setJWT(config.jwt || '');
22
+ this.setLocale(config.locale || 'en');
23
+ }
24
+ /**
25
+ * Set API endpoint
26
+ */
27
+ setEndpoint(endpoint) {
28
+ this.config.endpoint = endpoint;
29
+ return this;
30
+ }
31
+ /**
32
+ * Set project ID
33
+ */
34
+ setProject(project) {
35
+ this.config.project = project;
36
+ this.addHeader('X-Frontier-Project', project);
37
+ return this;
38
+ }
39
+ /**
40
+ * Set API key
41
+ */
42
+ setKey(key) {
43
+ this.config.key = key;
44
+ this.addHeader('X-Frontier-Key', key);
45
+ return this;
46
+ }
47
+ /**
48
+ * Set JWT token
49
+ */
50
+ setJWT(jwt) {
51
+ this.config.jwt = jwt;
52
+ this.addHeader('X-Frontier-JWT', jwt);
53
+ return this;
54
+ }
55
+ /**
56
+ * Set locale
57
+ */
58
+ setLocale(locale) {
59
+ this.headers['X-Frontier-Locale'] = locale;
60
+ return this;
61
+ }
62
+ /**
63
+ * Add custom header
64
+ */
65
+ addHeader(key, value) {
66
+ this.headers[key] = value;
67
+ return this;
68
+ }
69
+ /**
70
+ * Make HTTP request
71
+ */
72
+ async call(method, path = '', headers = {}, params = {}) {
73
+ const url = new URL(this.config.endpoint + path);
74
+ const options = {
75
+ method: method.toUpperCase(),
76
+ headers: { ...this.headers, ...headers },
77
+ };
78
+ if (method.toUpperCase() === 'GET') {
79
+ Object.keys(params).forEach(key => {
80
+ if (params[key] !== undefined) {
81
+ url.searchParams.append(key, params[key]);
82
+ }
83
+ });
84
+ }
85
+ else {
86
+ options.body = JSON.stringify(params);
87
+ }
88
+ try {
89
+ const response = await fetch(url.toString(), options);
90
+ let data;
91
+ try {
92
+ data = await response.json();
93
+ }
94
+ catch {
95
+ // If response is not JSON, use empty object
96
+ data = {};
97
+ }
98
+ if (!response.ok) {
99
+ throw new Error(data.message || `HTTP ${response.status}: ${response.statusText}`);
100
+ }
101
+ return data;
102
+ }
103
+ catch (error) {
104
+ throw error;
105
+ }
106
+ }
107
+ }
108
+ exports.Client = Client;
109
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAUH,MAAa,MAAM;IAUjB,YAAY,SAAuB,EAAE;QAT7B,WAAM,GAAiB,EAAE,CAAC;QAC1B,YAAO,GAA2B;YACxC,cAAc,EAAE,kBAAkB;YAClC,YAAY,EAAE,UAAU;YACxB,gBAAgB,EAAE,QAAQ;YAC1B,gBAAgB,EAAE,YAAY;YAC9B,eAAe,EAAE,OAAO;SACzB,CAAC;QAGA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;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,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;YACrF,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAnHD,wBAmHC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Custom exceptions for Frontier Auth SDK
3
+ */
4
+ export declare class FrontierException extends Error {
5
+ code: number;
6
+ type: string;
7
+ response: any;
8
+ constructor(message: string, code?: number, type?: string, response?: any);
9
+ }
10
+ export declare class AuthException extends FrontierException {
11
+ constructor(message: string, code?: number, type?: string, response?: any);
12
+ }
13
+ export declare class NetworkException extends FrontierException {
14
+ constructor(message: string, code?: number, type?: string, response?: any);
15
+ }
16
+ export declare class ValidationException extends FrontierException {
17
+ constructor(message: string, code?: number, type?: string, response?: any);
18
+ }
19
+ //# sourceMappingURL=exception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/exception.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,iBAAkB,SAAQ,KAAK;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,GAAG,CAAC;gBAET,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,EAAE,IAAI,GAAE,MAAW,EAAE,QAAQ,GAAE,GAAQ;CAOrF;AAED,qBAAa,aAAc,SAAQ,iBAAiB;gBACtC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAY,EAAE,IAAI,GAAE,MAAqB,EAAE,QAAQ,GAAE,GAAQ;CAIjG;AAED,qBAAa,gBAAiB,SAAQ,iBAAiB;gBACzC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,EAAE,IAAI,GAAE,MAAwB,EAAE,QAAQ,GAAE,GAAQ;CAIlG;AAED,qBAAa,mBAAoB,SAAQ,iBAAiB;gBAC5C,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAY,EAAE,IAAI,GAAE,MAA2B,EAAE,QAAQ,GAAE,GAAQ;CAIvG"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * Custom exceptions for Frontier Auth SDK
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ValidationException = exports.NetworkException = exports.AuthException = exports.FrontierException = void 0;
7
+ class FrontierException extends Error {
8
+ constructor(message, code = 0, type = '', response = '') {
9
+ super(message);
10
+ this.name = 'FrontierException';
11
+ this.code = code;
12
+ this.type = type;
13
+ this.response = response;
14
+ }
15
+ }
16
+ exports.FrontierException = FrontierException;
17
+ class AuthException extends FrontierException {
18
+ constructor(message, code = 401, type = 'auth_error', response = '') {
19
+ super(message, code, type, response);
20
+ this.name = 'AuthException';
21
+ }
22
+ }
23
+ exports.AuthException = AuthException;
24
+ class NetworkException extends FrontierException {
25
+ constructor(message, code = 0, type = 'network_error', response = '') {
26
+ super(message, code, type, response);
27
+ this.name = 'NetworkException';
28
+ }
29
+ }
30
+ exports.NetworkException = NetworkException;
31
+ class ValidationException extends FrontierException {
32
+ constructor(message, code = 400, type = 'validation_error', response = '') {
33
+ super(message, code, type, response);
34
+ this.name = 'ValidationException';
35
+ }
36
+ }
37
+ exports.ValidationException = ValidationException;
38
+ //# sourceMappingURL=exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception.js","sourceRoot":"","sources":["../../src/exceptions/exception.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,MAAa,iBAAkB,SAAQ,KAAK;IAK1C,YAAY,OAAe,EAAE,OAAe,CAAC,EAAE,OAAe,EAAE,EAAE,WAAgB,EAAE;QAClF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAZD,8CAYC;AAED,MAAa,aAAc,SAAQ,iBAAiB;IAClD,YAAY,OAAe,EAAE,OAAe,GAAG,EAAE,OAAe,YAAY,EAAE,WAAgB,EAAE;QAC9F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AALD,sCAKC;AAED,MAAa,gBAAiB,SAAQ,iBAAiB;IACrD,YAAY,OAAe,EAAE,OAAe,CAAC,EAAE,OAAe,eAAe,EAAE,WAAgB,EAAE;QAC/F,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC;AAED,MAAa,mBAAoB,SAAQ,iBAAiB;IACxD,YAAY,OAAe,EAAE,OAAe,GAAG,EAAE,OAAe,kBAAkB,EAAE,WAAgB,EAAE;QACpG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Frontier Auth SDK
3
+ * Main entry point for authentication SDK
4
+ */
5
+ import { Client } from './client.js';
6
+ import { Account } from './services/account.js';
7
+ export declare class FrontierAuth {
8
+ client: Client;
9
+ account: Account;
10
+ constructor();
11
+ /**
12
+ * Set the API endpoint
13
+ */
14
+ setEndpoint(endpoint: string): FrontierAuth;
15
+ /**
16
+ * Set the project ID
17
+ */
18
+ setProject(projectId: string): FrontierAuth;
19
+ /**
20
+ * Set the API key for server-side usage
21
+ */
22
+ setKey(key: string): FrontierAuth;
23
+ /**
24
+ * Set JWT token for authenticated requests
25
+ */
26
+ setJWT(jwt: string): FrontierAuth;
27
+ }
28
+ export { Client } from './client.js';
29
+ export { Account } from './services/account.js';
30
+ export * from './types/types.js';
31
+ export * from './exceptions/exception.js';
32
+ export default FrontierAuth;
33
+ //# 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,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,qBAAa,YAAY;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;;IAOxB;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY;IAK3C;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY;IAK3C;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;IAKjC;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;CAIlC;AAED,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAE1C,eAAe,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * Frontier Auth SDK
4
+ * Main entry point for authentication SDK
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.Account = exports.Client = exports.FrontierAuth = void 0;
22
+ const client_js_1 = require("./client.js");
23
+ const account_js_1 = require("./services/account.js");
24
+ class FrontierAuth {
25
+ constructor() {
26
+ this.client = new client_js_1.Client();
27
+ this.account = new account_js_1.Account(this.client);
28
+ }
29
+ /**
30
+ * Set the API endpoint
31
+ */
32
+ setEndpoint(endpoint) {
33
+ this.client.setEndpoint(endpoint);
34
+ return this;
35
+ }
36
+ /**
37
+ * Set the project ID
38
+ */
39
+ setProject(projectId) {
40
+ this.client.setProject(projectId);
41
+ return this;
42
+ }
43
+ /**
44
+ * Set the API key for server-side usage
45
+ */
46
+ setKey(key) {
47
+ this.client.setKey(key);
48
+ return this;
49
+ }
50
+ /**
51
+ * Set JWT token for authenticated requests
52
+ */
53
+ setJWT(jwt) {
54
+ this.client.setJWT(jwt);
55
+ return this;
56
+ }
57
+ }
58
+ exports.FrontierAuth = FrontierAuth;
59
+ var client_js_2 = require("./client.js");
60
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_js_2.Client; } });
61
+ var account_js_2 = require("./services/account.js");
62
+ Object.defineProperty(exports, "Account", { enumerable: true, get: function () { return account_js_2.Account; } });
63
+ __exportStar(require("./types/types.js"), exports);
64
+ __exportStar(require("./exceptions/exception.js"), exports);
65
+ exports.default = FrontierAuth;
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;AAEH,2CAAqC;AACrC,sDAAgD;AAEhD,MAAa,YAAY;IAIvB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,oBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,QAAgB;QAC1B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,SAAiB;QAC1B,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAxCD,oCAwCC;AAED,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AACf,oDAAgD;AAAvC,qGAAA,OAAO,OAAA;AAChB,mDAAiC;AACjC,4DAA0C;AAE1C,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Account service for user authentication
3
+ */
4
+ import { Client } from '../client.js';
5
+ import { User, Session } from '../types/types.js';
6
+ export declare class Account {
7
+ private client;
8
+ constructor(client: Client);
9
+ /**
10
+ * Create account (Sign up)
11
+ */
12
+ create(userId: string, email: string, password: string, name?: string): Promise<User>;
13
+ /**
14
+ * Create email session (Login)
15
+ */
16
+ createEmailSession(email: string, password: string): Promise<Session>;
17
+ }
18
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/services/account.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAElD,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAI1B;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3F;;OAEG;IACG,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAM5E"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * Account service for user authentication
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Account = void 0;
7
+ class Account {
8
+ constructor(client) {
9
+ this.client = client;
10
+ }
11
+ /**
12
+ * Create account (Sign up)
13
+ */
14
+ async create(userId, email, password, name) {
15
+ return await this.client.call('POST', '/account', {}, {
16
+ userId,
17
+ email,
18
+ password,
19
+ name
20
+ });
21
+ }
22
+ /**
23
+ * Create email session (Login)
24
+ */
25
+ async createEmailSession(email, password) {
26
+ return await this.client.call('POST', '/account/sessions/email', {}, {
27
+ email,
28
+ password
29
+ });
30
+ }
31
+ }
32
+ exports.Account = Account;
33
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/services/account.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAKH,MAAa,OAAO;IAGlB,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,KAAa,EAAE,QAAgB,EAAE,IAAa;QACzE,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE;YACpD,MAAM;YACN,KAAK;YACL,QAAQ;YACR,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CAAC,KAAa,EAAE,QAAgB;QACtD,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,yBAAyB,EAAE,EAAE,EAAE;YACnE,KAAK;YACL,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;CACF;AA5BD,0BA4BC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Type definitions for Frontier Auth SDK
3
+ */
4
+ export interface User {
5
+ $id: string;
6
+ $createdAt: string;
7
+ $updatedAt: string;
8
+ name: string;
9
+ email: string;
10
+ emailVerification: boolean;
11
+ status: boolean;
12
+ }
13
+ export interface Session {
14
+ $id: string;
15
+ $createdAt: string;
16
+ $updatedAt: string;
17
+ userId: string;
18
+ expire: string;
19
+ provider: string;
20
+ ip: string;
21
+ osCode: string;
22
+ osName: string;
23
+ osVersion: string;
24
+ clientType: string;
25
+ clientCode: string;
26
+ clientName: string;
27
+ clientVersion: string;
28
+ deviceName: string;
29
+ deviceBrand: string;
30
+ deviceModel: string;
31
+ countryCode: string;
32
+ countryName: string;
33
+ current: boolean;
34
+ }
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,IAAI;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Type definitions for Frontier Auth SDK
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Utility functions for Frontier Auth SDK
3
+ */
4
+ /**
5
+ * Generate a unique ID
6
+ */
7
+ export declare function generateId(): string;
8
+ /**
9
+ * Validate email format
10
+ */
11
+ export declare function isValidEmail(email: string): boolean;
12
+ /**
13
+ * Validate password strength
14
+ */
15
+ export declare function isValidPassword(password: string, minLength?: number): boolean;
16
+ /**
17
+ * Parse JWT token
18
+ */
19
+ export declare function parseJWT(token: string): any;
20
+ /**
21
+ * Check if JWT token is expired
22
+ */
23
+ export declare function isJWTExpired(token: string): boolean;
24
+ //# sourceMappingURL=security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/utils/security.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,OAAO,CAEhF;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAc3C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMnD"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * Utility functions for Frontier Auth SDK
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateId = generateId;
7
+ exports.isValidEmail = isValidEmail;
8
+ exports.isValidPassword = isValidPassword;
9
+ exports.parseJWT = parseJWT;
10
+ exports.isJWTExpired = isJWTExpired;
11
+ /**
12
+ * Generate a unique ID
13
+ */
14
+ function generateId() {
15
+ return Math.random().toString(36).substring(2) + Date.now().toString(36);
16
+ }
17
+ /**
18
+ * Validate email format
19
+ */
20
+ function isValidEmail(email) {
21
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
22
+ return emailRegex.test(email);
23
+ }
24
+ /**
25
+ * Validate password strength
26
+ */
27
+ function isValidPassword(password, minLength = 8) {
28
+ return password.length >= minLength;
29
+ }
30
+ /**
31
+ * Parse JWT token
32
+ */
33
+ function parseJWT(token) {
34
+ try {
35
+ const base64Url = token.split('.')[1];
36
+ const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
37
+ const jsonPayload = decodeURIComponent(atob(base64)
38
+ .split('')
39
+ .map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2))
40
+ .join(''));
41
+ return JSON.parse(jsonPayload);
42
+ }
43
+ catch (error) {
44
+ return null;
45
+ }
46
+ }
47
+ /**
48
+ * Check if JWT token is expired
49
+ */
50
+ function isJWTExpired(token) {
51
+ const payload = parseJWT(token);
52
+ if (!payload || !payload.exp) {
53
+ return true;
54
+ }
55
+ return Date.now() >= payload.exp * 1000;
56
+ }
57
+ //# sourceMappingURL=security.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/utils/security.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAKH,gCAEC;AAKD,oCAGC;AAKD,0CAEC;AAKD,4BAcC;AAKD,oCAMC;AAlDD;;GAEG;AACH,SAAgB,UAAU;IACxB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,KAAa;IACxC,MAAM,UAAU,GAAG,4BAA4B,CAAC;IAChD,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,QAAgB,EAAE,YAAoB,CAAC;IACrE,OAAO,QAAQ,CAAC,MAAM,IAAI,SAAS,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAgB,QAAQ,CAAC,KAAa;IACpC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC/D,MAAM,WAAW,GAAG,kBAAkB,CACpC,IAAI,CAAC,MAAM,CAAC;aACT,KAAK,CAAC,EAAE,CAAC;aACT,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC/D,IAAI,CAAC,EAAE,CAAC,CACZ,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,KAAa;IACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;AAC1C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@anujyadav070/frontier-sdk",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript SDK for Frontier authentication system",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*",
9
+ "README.md"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/anujyadav11a/Frontier-SDK"
14
+ },
15
+ "homepage": "https://github.com/anujyadav11a/Frontier-SDK",
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "dev": "tsc --watch",
19
+ "prepublishOnly": "npm run build",
20
+ "test": "echo \"Error: no test specified\" && exit 1"
21
+ },
22
+ "keywords": [
23
+ "SDK",
24
+ "fronteir"
25
+ ],
26
+ "author": "ANUJ YADAV",
27
+ "license": "ISC",
28
+ "publishConfig": {
29
+ "registry": "https://registry.npmjs.org/"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^25.3.0",
33
+ "typescript": "^5.9.3"
34
+ }
35
+ }