@tern-secure/auth 1.0.0 → 1.0.1

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.
@@ -37,10 +37,10 @@ function inBrowser() {
37
37
  return typeof window !== "undefined";
38
38
  }
39
39
  class TernSecureAuth {
40
- static version = "1.0.0";
40
+ static version = "1.0.1";
41
41
  static sdkMetadata = {
42
42
  name: "@tern-secure/auth",
43
- version: "1.0.0",
43
+ version: "1.0.1",
44
44
  environment: process.env.NODE_ENV || "production"
45
45
  };
46
46
  static instance = null;
@@ -22,10 +22,10 @@ function inBrowser() {
22
22
  return typeof window !== "undefined";
23
23
  }
24
24
  class TernSecureAuth {
25
- static version = "1.0.0";
25
+ static version = "1.0.1";
26
26
  static sdkMetadata = {
27
27
  name: "@tern-secure/auth",
28
- version: "1.0.0",
28
+ version: "1.0.1",
29
29
  environment: process.env.NODE_ENV || "production"
30
30
  };
31
31
  static instance = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tern-secure/auth",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TernSecure/typescript.git",
@@ -25,8 +25,8 @@
25
25
  "dependencies": {
26
26
  "server-only": "^0.0.1",
27
27
  "tslib": "2.4.1",
28
- "@tern-secure/shared": "1.2.0",
29
- "@tern-secure/types": "1.0.4"
28
+ "@tern-secure/shared": "1.2.1",
29
+ "@tern-secure/types": "1.0.5"
30
30
  },
31
31
  "devDependencies": {
32
32
  "firebase": "^12.0.0",
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var coreApiClient_example_exports = {};
20
- __export(coreApiClient_example_exports, {
21
- basicExample: () => basicExample,
22
- clientWithHooksExample: () => clientWithHooksExample,
23
- postExample: () => postExample
24
- });
25
- module.exports = __toCommonJS(coreApiClient_example_exports);
26
- var import_coreApiClient = require("./coreApiClient");
27
- async function basicExample() {
28
- var _a;
29
- try {
30
- const response = await import_coreApiClient.coreApiClient.request({
31
- path: "/users",
32
- method: "GET"
33
- //search: { limit: 10, offset: 0 }
34
- }, {
35
- apiUrl: "https://api.example.com",
36
- timeoutMs: 5e3
37
- });
38
- console.log("Users:", (_a = response.payload) == null ? void 0 : _a.response.users);
39
- } catch (error) {
40
- console.error("Failed to fetch users:", error);
41
- }
42
- }
43
- async function clientWithHooksExample() {
44
- var _a;
45
- const client = new import_coreApiClient.CoreApiClient({
46
- apiUrl: "https://api.example.com",
47
- timeoutMs: 1e4,
48
- failureThreshold: 3,
49
- maxTries: 5
50
- });
51
- client.onBeforeRequest(() => {
52
- const token = localStorage.getItem("auth_token");
53
- return !!token;
54
- });
55
- client.onAfterResponse((response) => {
56
- console.log(`Response: ${response.status}`);
57
- return true;
58
- });
59
- try {
60
- const response = await client.request({
61
- path: "/protected-resource",
62
- method: "GET",
63
- sessionId: "user-session-123"
64
- });
65
- console.log("Protected data:", (_a = response.payload) == null ? void 0 : _a.response);
66
- } catch (error) {
67
- console.error("Request failed:", error);
68
- }
69
- }
70
- async function postExample() {
71
- var _a;
72
- try {
73
- const response = await import_coreApiClient.coreApiClient.request({
74
- path: "/users",
75
- method: "POST",
76
- body: {
77
- firstName: "John",
78
- lastName: "Doe",
79
- emailAddress: "john.doe@example.com"
80
- }
81
- // Cast to any since our implementation handles object-to-form conversion
82
- }, {
83
- apiUrl: "https://api.example.com"
84
- });
85
- console.log("Created user:", (_a = response.payload) == null ? void 0 : _a.response);
86
- } catch (error) {
87
- console.error("Failed to create user:", error);
88
- }
89
- }
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {
92
- basicExample,
93
- clientWithHooksExample,
94
- postExample
95
- });
96
- //# sourceMappingURL=coreApiClient.example.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/instance/coreApiClient.example.ts"],"sourcesContent":["/**\n * Example usage of CoreApiClient\n */\n\nimport { CoreApiClient, coreApiClient } from './coreApiClient';\n\n// Example 1: Basic usage with default instance\nasync function basicExample() {\n try {\n const response = await coreApiClient.request<{ users: any[] }>({\n path: '/users',\n method: 'GET',\n //search: { limit: 10, offset: 0 }\n }, {\n apiUrl: 'https://api.example.com',\n timeoutMs: 5000\n });\n\n console.log('Users:', response.payload?.response.users);\n } catch (error) {\n console.error('Failed to fetch users:', error);\n }\n}\n\n// Example 2: Custom client with hooks\nasync function clientWithHooksExample() {\n const client = new CoreApiClient({\n apiUrl: 'https://api.example.com',\n timeoutMs: 10000,\n failureThreshold: 3,\n maxTries: 5\n });\n\n // Add authentication hook\n client.onBeforeRequest(() => {\n const token = localStorage.getItem('auth_token');\n return !!token; // Only proceed if token exists\n });\n\n // Add logging hook\n client.onAfterResponse((response) => {\n console.log(`Response: ${response.status}`);\n return true;\n });\n\n try {\n const response = await client.request({\n path: '/protected-resource',\n method: 'GET',\n sessionId: 'user-session-123'\n });\n\n console.log('Protected data:', response.payload?.response);\n } catch (error) {\n console.error('Request failed:', error);\n }\n}\n\n// Example 3: POST request with form data\nasync function postExample() {\n try {\n const response = await coreApiClient.request({\n path: '/users',\n method: 'POST',\n body: {\n firstName: 'John',\n lastName: 'Doe',\n emailAddress: 'john.doe@example.com'\n } as any // Cast to any since our implementation handles object-to-form conversion\n }, {\n apiUrl: 'https://api.example.com'\n });\n\n console.log('Created user:', response.payload?.response);\n } catch (error) {\n console.error('Failed to create user:', error);\n }\n}\n\nexport { basicExample, clientWithHooksExample, postExample };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,2BAA6C;AAG7C,eAAe,eAAe;AAP9B;AAQE,MAAI;AACF,UAAM,WAAW,MAAM,mCAAc,QAA0B;AAAA,MAC7D,MAAM;AAAA,MACN,QAAQ;AAAA;AAAA,IAEV,GAAG;AAAA,MACD,QAAQ;AAAA,MACR,WAAW;AAAA,IACb,CAAC;AAED,YAAQ,IAAI,WAAU,cAAS,YAAT,mBAAkB,SAAS,KAAK;AAAA,EACxD,SAAS,OAAO;AACd,YAAQ,MAAM,0BAA0B,KAAK;AAAA,EAC/C;AACF;AAGA,eAAe,yBAAyB;AAzBxC;AA0BE,QAAM,SAAS,IAAI,mCAAc;AAAA,IAC/B,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,UAAU;AAAA,EACZ,CAAC;AAGD,SAAO,gBAAgB,MAAM;AAC3B,UAAM,QAAQ,aAAa,QAAQ,YAAY;AAC/C,WAAO,CAAC,CAAC;AAAA,EACX,CAAC;AAGD,SAAO,gBAAgB,CAAC,aAAa;AACnC,YAAQ,IAAI,aAAa,SAAS,MAAM,EAAE;AAC1C,WAAO;AAAA,EACT,CAAC;AAED,MAAI;AACF,UAAM,WAAW,MAAM,OAAO,QAAQ;AAAA,MACpC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,WAAW;AAAA,IACb,CAAC;AAED,YAAQ,IAAI,oBAAmB,cAAS,YAAT,mBAAkB,QAAQ;AAAA,EAC3D,SAAS,OAAO;AACd,YAAQ,MAAM,mBAAmB,KAAK;AAAA,EACxC;AACF;AAGA,eAAe,cAAc;AA3D7B;AA4DE,MAAI;AACF,UAAM,WAAW,MAAM,mCAAc,QAAQ;AAAA,MAC3C,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,QACJ,WAAW;AAAA,QACX,UAAU;AAAA,QACV,cAAc;AAAA,MAChB;AAAA;AAAA,IACF,GAAG;AAAA,MACD,QAAQ;AAAA,IACV,CAAC;AAED,YAAQ,IAAI,kBAAiB,cAAS,YAAT,mBAAkB,QAAQ;AAAA,EACzD,SAAS,OAAO;AACd,YAAQ,MAAM,0BAA0B,KAAK;AAAA,EAC/C;AACF;","names":[]}
@@ -1,70 +0,0 @@
1
- import { CoreApiClient, coreApiClient } from "./coreApiClient";
2
- async function basicExample() {
3
- var _a;
4
- try {
5
- const response = await coreApiClient.request({
6
- path: "/users",
7
- method: "GET"
8
- //search: { limit: 10, offset: 0 }
9
- }, {
10
- apiUrl: "https://api.example.com",
11
- timeoutMs: 5e3
12
- });
13
- console.log("Users:", (_a = response.payload) == null ? void 0 : _a.response.users);
14
- } catch (error) {
15
- console.error("Failed to fetch users:", error);
16
- }
17
- }
18
- async function clientWithHooksExample() {
19
- var _a;
20
- const client = new CoreApiClient({
21
- apiUrl: "https://api.example.com",
22
- timeoutMs: 1e4,
23
- failureThreshold: 3,
24
- maxTries: 5
25
- });
26
- client.onBeforeRequest(() => {
27
- const token = localStorage.getItem("auth_token");
28
- return !!token;
29
- });
30
- client.onAfterResponse((response) => {
31
- console.log(`Response: ${response.status}`);
32
- return true;
33
- });
34
- try {
35
- const response = await client.request({
36
- path: "/protected-resource",
37
- method: "GET",
38
- sessionId: "user-session-123"
39
- });
40
- console.log("Protected data:", (_a = response.payload) == null ? void 0 : _a.response);
41
- } catch (error) {
42
- console.error("Request failed:", error);
43
- }
44
- }
45
- async function postExample() {
46
- var _a;
47
- try {
48
- const response = await coreApiClient.request({
49
- path: "/users",
50
- method: "POST",
51
- body: {
52
- firstName: "John",
53
- lastName: "Doe",
54
- emailAddress: "john.doe@example.com"
55
- }
56
- // Cast to any since our implementation handles object-to-form conversion
57
- }, {
58
- apiUrl: "https://api.example.com"
59
- });
60
- console.log("Created user:", (_a = response.payload) == null ? void 0 : _a.response);
61
- } catch (error) {
62
- console.error("Failed to create user:", error);
63
- }
64
- }
65
- export {
66
- basicExample,
67
- clientWithHooksExample,
68
- postExample
69
- };
70
- //# sourceMappingURL=coreApiClient.example.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/instance/coreApiClient.example.ts"],"sourcesContent":["/**\n * Example usage of CoreApiClient\n */\n\nimport { CoreApiClient, coreApiClient } from './coreApiClient';\n\n// Example 1: Basic usage with default instance\nasync function basicExample() {\n try {\n const response = await coreApiClient.request<{ users: any[] }>({\n path: '/users',\n method: 'GET',\n //search: { limit: 10, offset: 0 }\n }, {\n apiUrl: 'https://api.example.com',\n timeoutMs: 5000\n });\n\n console.log('Users:', response.payload?.response.users);\n } catch (error) {\n console.error('Failed to fetch users:', error);\n }\n}\n\n// Example 2: Custom client with hooks\nasync function clientWithHooksExample() {\n const client = new CoreApiClient({\n apiUrl: 'https://api.example.com',\n timeoutMs: 10000,\n failureThreshold: 3,\n maxTries: 5\n });\n\n // Add authentication hook\n client.onBeforeRequest(() => {\n const token = localStorage.getItem('auth_token');\n return !!token; // Only proceed if token exists\n });\n\n // Add logging hook\n client.onAfterResponse((response) => {\n console.log(`Response: ${response.status}`);\n return true;\n });\n\n try {\n const response = await client.request({\n path: '/protected-resource',\n method: 'GET',\n sessionId: 'user-session-123'\n });\n\n console.log('Protected data:', response.payload?.response);\n } catch (error) {\n console.error('Request failed:', error);\n }\n}\n\n// Example 3: POST request with form data\nasync function postExample() {\n try {\n const response = await coreApiClient.request({\n path: '/users',\n method: 'POST',\n body: {\n firstName: 'John',\n lastName: 'Doe',\n emailAddress: 'john.doe@example.com'\n } as any // Cast to any since our implementation handles object-to-form conversion\n }, {\n apiUrl: 'https://api.example.com'\n });\n\n console.log('Created user:', response.payload?.response);\n } catch (error) {\n console.error('Failed to create user:', error);\n }\n}\n\nexport { basicExample, clientWithHooksExample, postExample };\n"],"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,kBAAiB,cAAS,YAAT,mBAAkB,QAAQ;AAAA,EACzD,SAAS,OAAO;AACd,YAAQ,MAAM,0BAA0B,KAAK;AAAA,EAC/C;AACF;","names":[]}
@@ -1,8 +0,0 @@
1
- /**
2
- * Example usage of CoreApiClient
3
- */
4
- declare function basicExample(): Promise<void>;
5
- declare function clientWithHooksExample(): Promise<void>;
6
- declare function postExample(): Promise<void>;
7
- export { basicExample, clientWithHooksExample, postExample };
8
- //# sourceMappingURL=coreApiClient.example.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"coreApiClient.example.d.ts","sourceRoot":"","sources":["../../../src/instance/coreApiClient.example.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,iBAAe,YAAY,kBAe1B;AAGD,iBAAe,sBAAsB,kBA+BpC;AAGD,iBAAe,WAAW,kBAkBzB;AAED,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,WAAW,EAAE,CAAC"}