@auditauth/core 0.2.0-beta.2 → 0.2.0-beta.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.
Files changed (50) hide show
  1. package/README.md +11 -0
  2. package/dist/auth/authorizeCode.cjs +42 -0
  3. package/dist/auth/authorizeCode.d.cts +20 -0
  4. package/dist/auth/authorizeCode.d.ts +4 -2
  5. package/dist/auth/authorizeCode.js +20 -18
  6. package/dist/auth/buildAuthUrl.cjs +44 -0
  7. package/dist/auth/buildAuthUrl.d.cts +9 -0
  8. package/dist/auth/buildAuthUrl.d.ts +5 -2
  9. package/dist/auth/buildAuthUrl.js +22 -19
  10. package/dist/auth/index.cjs +47 -0
  11. package/dist/auth/index.d.cts +6 -0
  12. package/dist/auth/index.d.ts +2 -0
  13. package/dist/auth/index.js +10 -4
  14. package/dist/auth/refreshTokens.cjs +36 -0
  15. package/dist/auth/refreshTokens.d.cts +9 -0
  16. package/dist/auth/refreshTokens.d.ts +4 -2
  17. package/dist/auth/refreshTokens.js +14 -12
  18. package/dist/auth/revokeSession.cjs +34 -0
  19. package/dist/auth/revokeSession.d.cts +6 -0
  20. package/dist/auth/revokeSession.d.ts +2 -1
  21. package/dist/auth/revokeSession.js +12 -9
  22. package/dist/index.cjs +28 -0
  23. package/dist/index.d.cts +9 -0
  24. package/dist/index.d.ts +9 -5
  25. package/dist/index.js +4 -4
  26. package/dist/metrics/index.cjs +38 -0
  27. package/dist/metrics/index.d.cts +2 -0
  28. package/dist/metrics/index.d.ts +1 -0
  29. package/dist/metrics/index.js +4 -1
  30. package/dist/metrics/sendMetrics.cjs +34 -0
  31. package/dist/metrics/sendMetrics.d.cts +10 -0
  32. package/dist/metrics/sendMetrics.d.ts +4 -2
  33. package/dist/metrics/sendMetrics.js +12 -9
  34. package/dist/portal/buildPortalUrl.cjs +43 -0
  35. package/dist/portal/buildPortalUrl.d.cts +9 -0
  36. package/dist/portal/buildPortalUrl.d.ts +5 -2
  37. package/dist/portal/buildPortalUrl.js +20 -17
  38. package/dist/portal/index.cjs +38 -0
  39. package/dist/portal/index.d.cts +2 -0
  40. package/dist/portal/index.d.ts +1 -0
  41. package/dist/portal/index.js +4 -1
  42. package/dist/settings.cjs +64 -0
  43. package/dist/settings.d.cts +20 -0
  44. package/dist/settings.d.ts +4 -3
  45. package/dist/settings.js +32 -31
  46. package/dist/types.cjs +16 -0
  47. package/dist/types.d.cts +44 -0
  48. package/dist/types.d.ts +2 -1
  49. package/dist/types.js +0 -1
  50. package/package.json +10 -5
package/README.md CHANGED
@@ -12,6 +12,17 @@ Install the package in your project.
12
12
  npm install @auditauth/core
13
13
  ```
14
14
 
15
+ ## TypeScript import compatibility
16
+
17
+ `@auditauth/core` ships dual module output (ESM + CJS) with declaration files.
18
+ You can import it in TypeScript projects with standard syntax:
19
+
20
+ ```ts
21
+ import { CORE_SETTINGS } from '@auditauth/core'
22
+ ```
23
+
24
+ You do not need to append `.js` in consumer imports.
25
+
15
26
  ## Minimal example
16
27
 
17
28
  Import and use the core helpers directly.
@@ -0,0 +1,42 @@
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 authorizeCode_exports = {};
20
+ __export(authorizeCode_exports, {
21
+ default: () => authorizeCode_default
22
+ });
23
+ module.exports = __toCommonJS(authorizeCode_exports);
24
+ var import_settings = require("../settings.cjs");
25
+ const authorizeCode = async ({ code, client_type }) => {
26
+ if (!code) throw new Error("Invalid code");
27
+ const response = await fetch(`${import_settings.CORE_SETTINGS.domains.api}/auth/authorize`, {
28
+ method: "POST",
29
+ headers: { "Content-Type": "application/json" },
30
+ body: JSON.stringify({ code, client_type }),
31
+ credentials: "include"
32
+ });
33
+ if (!response.ok) {
34
+ throw new Error("Unauthorized");
35
+ }
36
+ const data = await response.json();
37
+ return {
38
+ response,
39
+ data
40
+ };
41
+ };
42
+ var authorizeCode_default = authorizeCode;
@@ -0,0 +1,20 @@
1
+ import { SessionUser } from '../types.cjs';
2
+
3
+ type AuthorizePayload = {
4
+ code: string | null;
5
+ client_type: 'browser' | 'server';
6
+ };
7
+ type AuthorizeData = {
8
+ user: SessionUser;
9
+ access_token: string;
10
+ access_expires_seconds: number;
11
+ refresh_token?: string;
12
+ refresh_expires_seconds: number;
13
+ };
14
+ type AuthorizeReturns = {
15
+ response: Response;
16
+ data: AuthorizeData;
17
+ };
18
+ declare const authorizeCode: ({ code, client_type }: AuthorizePayload) => Promise<AuthorizeReturns>;
19
+
20
+ export { authorizeCode as default };
@@ -1,4 +1,5 @@
1
- import type { SessionUser } from '../types.js';
1
+ import { SessionUser } from '../types.js';
2
+
2
3
  type AuthorizePayload = {
3
4
  code: string | null;
4
5
  client_type: 'browser' | 'server';
@@ -15,4 +16,5 @@ type AuthorizeReturns = {
15
16
  data: AuthorizeData;
16
17
  };
17
18
  declare const authorizeCode: ({ code, client_type }: AuthorizePayload) => Promise<AuthorizeReturns>;
18
- export default authorizeCode;
19
+
20
+ export { authorizeCode as default };
@@ -1,20 +1,22 @@
1
- import { CORE_SETTINGS } from '../settings.js';
1
+ import { CORE_SETTINGS } from "../settings.js";
2
2
  const authorizeCode = async ({ code, client_type }) => {
3
- if (!code)
4
- throw new Error('Invalid code');
5
- const response = await fetch(`${CORE_SETTINGS.domains.api}/auth/authorize`, {
6
- method: 'POST',
7
- headers: { 'Content-Type': 'application/json' },
8
- body: JSON.stringify({ code, client_type }),
9
- credentials: 'include',
10
- });
11
- if (!response.ok) {
12
- throw new Error('Unauthorized');
13
- }
14
- const data = await response.json();
15
- return {
16
- response,
17
- data: data,
18
- };
3
+ if (!code) throw new Error("Invalid code");
4
+ const response = await fetch(`${CORE_SETTINGS.domains.api}/auth/authorize`, {
5
+ method: "POST",
6
+ headers: { "Content-Type": "application/json" },
7
+ body: JSON.stringify({ code, client_type }),
8
+ credentials: "include"
9
+ });
10
+ if (!response.ok) {
11
+ throw new Error("Unauthorized");
12
+ }
13
+ const data = await response.json();
14
+ return {
15
+ response,
16
+ data
17
+ };
18
+ };
19
+ var authorizeCode_default = authorizeCode;
20
+ export {
21
+ authorizeCode_default as default
19
22
  };
20
- export default authorizeCode;
@@ -0,0 +1,44 @@
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 buildAuthUrl_exports = {};
20
+ __export(buildAuthUrl_exports, {
21
+ default: () => buildAuthUrl_default
22
+ });
23
+ module.exports = __toCommonJS(buildAuthUrl_exports);
24
+ var import_settings = require("../settings.cjs");
25
+ const buildAuthUrl = async ({ apiKey, redirectUrl }) => {
26
+ const response = await fetch(`${import_settings.CORE_SETTINGS.domains.api}/applications/login`, {
27
+ method: "POST",
28
+ headers: {
29
+ "Content-Type": "application/json",
30
+ "x-api-key": apiKey
31
+ },
32
+ body: JSON.stringify({ redirect_url: redirectUrl })
33
+ });
34
+ if (!response.ok) {
35
+ const error = await response.text();
36
+ throw new Error(error);
37
+ }
38
+ const body = await response.json();
39
+ const { redirectUrl: authRedirectUrl, code } = body;
40
+ const url = new URL(authRedirectUrl);
41
+ url.searchParams.set("code", code);
42
+ return url;
43
+ };
44
+ var buildAuthUrl_default = buildAuthUrl;
@@ -0,0 +1,9 @@
1
+ import * as url from 'url';
2
+
3
+ type BuildAuthUrlPayload = {
4
+ apiKey: string;
5
+ redirectUrl: string;
6
+ };
7
+ declare const buildAuthUrl: ({ apiKey, redirectUrl }: BuildAuthUrlPayload) => Promise<url.URL>;
8
+
9
+ export { buildAuthUrl as default };
@@ -1,6 +1,9 @@
1
+ import * as url from 'url';
2
+
1
3
  type BuildAuthUrlPayload = {
2
4
  apiKey: string;
3
5
  redirectUrl: string;
4
6
  };
5
- declare const buildAuthUrl: ({ apiKey, redirectUrl }: BuildAuthUrlPayload) => Promise<import("url").URL>;
6
- export default buildAuthUrl;
7
+ declare const buildAuthUrl: ({ apiKey, redirectUrl }: BuildAuthUrlPayload) => Promise<url.URL>;
8
+
9
+ export { buildAuthUrl as default };
@@ -1,21 +1,24 @@
1
- import { CORE_SETTINGS } from '../settings.js';
1
+ import { CORE_SETTINGS } from "../settings.js";
2
2
  const buildAuthUrl = async ({ apiKey, redirectUrl }) => {
3
- const response = await fetch(`${CORE_SETTINGS.domains.api}/applications/login`, {
4
- method: 'POST',
5
- headers: {
6
- 'Content-Type': 'application/json',
7
- 'x-api-key': apiKey,
8
- },
9
- body: JSON.stringify({ redirect_url: redirectUrl }),
10
- });
11
- if (!response.ok) {
12
- const error = await response.text();
13
- throw new Error(error);
14
- }
15
- const body = await response.json();
16
- const { redirectUrl: authRedirectUrl, code } = body;
17
- const url = new URL(authRedirectUrl);
18
- url.searchParams.set('code', code);
19
- return url;
3
+ const response = await fetch(`${CORE_SETTINGS.domains.api}/applications/login`, {
4
+ method: "POST",
5
+ headers: {
6
+ "Content-Type": "application/json",
7
+ "x-api-key": apiKey
8
+ },
9
+ body: JSON.stringify({ redirect_url: redirectUrl })
10
+ });
11
+ if (!response.ok) {
12
+ const error = await response.text();
13
+ throw new Error(error);
14
+ }
15
+ const body = await response.json();
16
+ const { redirectUrl: authRedirectUrl, code } = body;
17
+ const url = new URL(authRedirectUrl);
18
+ url.searchParams.set("code", code);
19
+ return url;
20
+ };
21
+ var buildAuthUrl_default = buildAuthUrl;
22
+ export {
23
+ buildAuthUrl_default as default
20
24
  };
21
- export default buildAuthUrl;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var auth_exports = {};
30
+ __export(auth_exports, {
31
+ authorizeCode: () => import_authorizeCode.default,
32
+ buildAuthUrl: () => import_buildAuthUrl.default,
33
+ refreshTokens: () => import_refreshTokens.default,
34
+ revokeSession: () => import_revokeSession.default
35
+ });
36
+ module.exports = __toCommonJS(auth_exports);
37
+ var import_buildAuthUrl = __toESM(require("./buildAuthUrl.cjs"), 1);
38
+ var import_authorizeCode = __toESM(require("./authorizeCode.cjs"), 1);
39
+ var import_revokeSession = __toESM(require("./revokeSession.cjs"), 1);
40
+ var import_refreshTokens = __toESM(require("./refreshTokens.cjs"), 1);
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ authorizeCode,
44
+ buildAuthUrl,
45
+ refreshTokens,
46
+ revokeSession
47
+ });
@@ -0,0 +1,6 @@
1
+ export { default as buildAuthUrl } from './buildAuthUrl.cjs';
2
+ export { default as authorizeCode } from './authorizeCode.cjs';
3
+ export { default as revokeSession } from './revokeSession.cjs';
4
+ export { default as refreshTokens } from './refreshTokens.cjs';
5
+ import 'url';
6
+ import '../types.cjs';
@@ -2,3 +2,5 @@ export { default as buildAuthUrl } from './buildAuthUrl.js';
2
2
  export { default as authorizeCode } from './authorizeCode.js';
3
3
  export { default as revokeSession } from './revokeSession.js';
4
4
  export { default as refreshTokens } from './refreshTokens.js';
5
+ import 'url';
6
+ import '../types.js';
@@ -1,4 +1,10 @@
1
- export { default as buildAuthUrl } from './buildAuthUrl.js';
2
- export { default as authorizeCode } from './authorizeCode.js';
3
- export { default as revokeSession } from './revokeSession.js';
4
- export { default as refreshTokens } from './refreshTokens.js';
1
+ import { default as default2 } from "./buildAuthUrl.js";
2
+ import { default as default3 } from "./authorizeCode.js";
3
+ import { default as default4 } from "./revokeSession.js";
4
+ import { default as default5 } from "./refreshTokens.js";
5
+ export {
6
+ default3 as authorizeCode,
7
+ default2 as buildAuthUrl,
8
+ default5 as refreshTokens,
9
+ default4 as revokeSession
10
+ };
@@ -0,0 +1,36 @@
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 refreshTokens_exports = {};
20
+ __export(refreshTokens_exports, {
21
+ default: () => refreshTokens_default
22
+ });
23
+ module.exports = __toCommonJS(refreshTokens_exports);
24
+ var import_settings = require("../settings.cjs");
25
+ const refreshTokens = async ({ client_type, refresh_token }) => {
26
+ const response = await fetch(`${import_settings.CORE_SETTINGS.domains.api}/auth/refresh`, {
27
+ method: "POST",
28
+ credentials: "include",
29
+ headers: { "Content-Type": "application/json" },
30
+ body: JSON.stringify({ client_type, refresh_token })
31
+ });
32
+ if (!response.ok) return null;
33
+ const data = await response.json();
34
+ return data;
35
+ };
36
+ var refreshTokens_default = refreshTokens;
@@ -0,0 +1,9 @@
1
+ import { CredentialsResponse } from '../types.cjs';
2
+
3
+ type RefreshTokensPayload = {
4
+ client_type: 'browser' | 'server';
5
+ refresh_token?: string;
6
+ };
7
+ declare const refreshTokens: ({ client_type, refresh_token }: RefreshTokensPayload) => Promise<CredentialsResponse | null>;
8
+
9
+ export { refreshTokens as default };
@@ -1,7 +1,9 @@
1
- import type { CredentialsResponse } from '../types.js';
1
+ import { CredentialsResponse } from '../types.js';
2
+
2
3
  type RefreshTokensPayload = {
3
4
  client_type: 'browser' | 'server';
4
5
  refresh_token?: string;
5
6
  };
6
7
  declare const refreshTokens: ({ client_type, refresh_token }: RefreshTokensPayload) => Promise<CredentialsResponse | null>;
7
- export default refreshTokens;
8
+
9
+ export { refreshTokens as default };
@@ -1,14 +1,16 @@
1
- import { CORE_SETTINGS } from '../settings.js';
1
+ import { CORE_SETTINGS } from "../settings.js";
2
2
  const refreshTokens = async ({ client_type, refresh_token }) => {
3
- const response = await fetch(`${CORE_SETTINGS.domains.api}/auth/refresh`, {
4
- method: 'POST',
5
- credentials: 'include',
6
- headers: { 'Content-Type': 'application/json' },
7
- body: JSON.stringify({ client_type, refresh_token }),
8
- });
9
- if (!response.ok)
10
- return null;
11
- const data = await response.json();
12
- return data;
3
+ const response = await fetch(`${CORE_SETTINGS.domains.api}/auth/refresh`, {
4
+ method: "POST",
5
+ credentials: "include",
6
+ headers: { "Content-Type": "application/json" },
7
+ body: JSON.stringify({ client_type, refresh_token })
8
+ });
9
+ if (!response.ok) return null;
10
+ const data = await response.json();
11
+ return data;
12
+ };
13
+ var refreshTokens_default = refreshTokens;
14
+ export {
15
+ refreshTokens_default as default
13
16
  };
14
- export default refreshTokens;
@@ -0,0 +1,34 @@
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 revokeSession_exports = {};
20
+ __export(revokeSession_exports, {
21
+ default: () => revokeSession_default
22
+ });
23
+ module.exports = __toCommonJS(revokeSession_exports);
24
+ var import_settings = require("../settings.cjs");
25
+ const revokeSession = async ({ access_token }) => {
26
+ const response = await fetch(`${import_settings.CORE_SETTINGS.domains.api}/auth/revoke`, {
27
+ method: "PATCH",
28
+ headers: { Authorization: `Bearer ${access_token}` }
29
+ });
30
+ if (!response.ok) {
31
+ throw new Error("Error revoking session");
32
+ }
33
+ };
34
+ var revokeSession_default = revokeSession;
@@ -0,0 +1,6 @@
1
+ type RevokeSessionPayload = {
2
+ access_token?: string;
3
+ };
4
+ declare const revokeSession: ({ access_token }: RevokeSessionPayload) => Promise<void>;
5
+
6
+ export { revokeSession as default };
@@ -2,4 +2,5 @@ type RevokeSessionPayload = {
2
2
  access_token?: string;
3
3
  };
4
4
  declare const revokeSession: ({ access_token }: RevokeSessionPayload) => Promise<void>;
5
- export default revokeSession;
5
+
6
+ export { revokeSession as default };
@@ -1,11 +1,14 @@
1
- import { CORE_SETTINGS } from '../settings.js';
1
+ import { CORE_SETTINGS } from "../settings.js";
2
2
  const revokeSession = async ({ access_token }) => {
3
- const response = await fetch(`${CORE_SETTINGS.domains.api}/auth/revoke`, {
4
- method: 'PATCH',
5
- headers: { Authorization: `Bearer ${access_token}` },
6
- });
7
- if (!response.ok) {
8
- throw new Error('Error revoking session');
9
- }
3
+ const response = await fetch(`${CORE_SETTINGS.domains.api}/auth/revoke`, {
4
+ method: "PATCH",
5
+ headers: { Authorization: `Bearer ${access_token}` }
6
+ });
7
+ if (!response.ok) {
8
+ throw new Error("Error revoking session");
9
+ }
10
+ };
11
+ var revokeSession_default = revokeSession;
12
+ export {
13
+ revokeSession_default as default
10
14
  };
11
- export default revokeSession;
package/dist/index.cjs ADDED
@@ -0,0 +1,28 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./settings.cjs"), module.exports);
19
+ __reExport(index_exports, require("./auth/index.cjs"), module.exports);
20
+ __reExport(index_exports, require("./portal/index.cjs"), module.exports);
21
+ __reExport(index_exports, require("./metrics/index.cjs"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./settings.cjs"),
25
+ ...require("./auth/index.cjs"),
26
+ ...require("./portal/index.cjs"),
27
+ ...require("./metrics/index.cjs")
28
+ });
@@ -0,0 +1,9 @@
1
+ export { CORE_SETTINGS } from './settings.cjs';
2
+ export { AuditAuthConfig, CredentialsResponse, Metric, RequestMethod, SessionUser } from './types.cjs';
3
+ export { default as buildAuthUrl } from './auth/buildAuthUrl.cjs';
4
+ export { default as authorizeCode } from './auth/authorizeCode.cjs';
5
+ export { default as revokeSession } from './auth/revokeSession.cjs';
6
+ export { default as refreshTokens } from './auth/refreshTokens.cjs';
7
+ export { default as buildPortalUrl } from './portal/buildPortalUrl.cjs';
8
+ export { default as sendMetrics } from './metrics/sendMetrics.cjs';
9
+ import 'url';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
- export * from './settings.js';
2
- export type * from './types.js';
3
- export * from './auth/index.js';
4
- export * from './portal/index.js';
5
- export * from './metrics/index.js';
1
+ export { CORE_SETTINGS } from './settings.js';
2
+ export { AuditAuthConfig, CredentialsResponse, Metric, RequestMethod, SessionUser } from './types.js';
3
+ export { default as buildAuthUrl } from './auth/buildAuthUrl.js';
4
+ export { default as authorizeCode } from './auth/authorizeCode.js';
5
+ export { default as revokeSession } from './auth/revokeSession.js';
6
+ export { default as refreshTokens } from './auth/refreshTokens.js';
7
+ export { default as buildPortalUrl } from './portal/buildPortalUrl.js';
8
+ export { default as sendMetrics } from './metrics/sendMetrics.js';
9
+ import 'url';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from './settings.js';
2
- export * from './auth/index.js';
3
- export * from './portal/index.js';
4
- export * from './metrics/index.js';
1
+ export * from "./settings.js";
2
+ export * from "./auth/index.js";
3
+ export * from "./portal/index.js";
4
+ export * from "./metrics/index.js";
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var metrics_exports = {};
30
+ __export(metrics_exports, {
31
+ sendMetrics: () => import_sendMetrics.default
32
+ });
33
+ module.exports = __toCommonJS(metrics_exports);
34
+ var import_sendMetrics = __toESM(require("./sendMetrics.cjs"), 1);
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ sendMetrics
38
+ });
@@ -0,0 +1,2 @@
1
+ export { default as sendMetrics } from './sendMetrics.cjs';
2
+ import '../types.cjs';
@@ -1 +1,2 @@
1
1
  export { default as sendMetrics } from './sendMetrics.js';
2
+ import '../types.js';
@@ -1 +1,4 @@
1
- export { default as sendMetrics } from './sendMetrics.js';
1
+ import { default as default2 } from "./sendMetrics.js";
2
+ export {
3
+ default2 as sendMetrics
4
+ };
@@ -0,0 +1,34 @@
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 sendMetrics_exports = {};
20
+ __export(sendMetrics_exports, {
21
+ default: () => sendMetrics_default
22
+ });
23
+ module.exports = __toCommonJS(sendMetrics_exports);
24
+ var import_settings = require("../settings.cjs");
25
+ const sendMetrics = async ({ apiKey, appId, payload }) => {
26
+ await fetch(`${import_settings.CORE_SETTINGS.domains.api}/metrics`, {
27
+ method: "POST",
28
+ headers: {
29
+ "Content-Type": "application/json"
30
+ },
31
+ body: JSON.stringify({ ...payload, appId, apiKey })
32
+ });
33
+ };
34
+ var sendMetrics_default = sendMetrics;
@@ -0,0 +1,10 @@
1
+ import { Metric } from '../types.cjs';
2
+
3
+ type SendMetricsPayload = {
4
+ payload: Metric;
5
+ appId: string;
6
+ apiKey: string;
7
+ };
8
+ declare const sendMetrics: ({ apiKey, appId, payload }: SendMetricsPayload) => Promise<void>;
9
+
10
+ export { sendMetrics as default };
@@ -1,8 +1,10 @@
1
- import type { Metric } from '../types.js';
1
+ import { Metric } from '../types.js';
2
+
2
3
  type SendMetricsPayload = {
3
4
  payload: Metric;
4
5
  appId: string;
5
6
  apiKey: string;
6
7
  };
7
8
  declare const sendMetrics: ({ apiKey, appId, payload }: SendMetricsPayload) => Promise<void>;
8
- export default sendMetrics;
9
+
10
+ export { sendMetrics as default };
@@ -1,11 +1,14 @@
1
- import { CORE_SETTINGS } from '../settings.js';
1
+ import { CORE_SETTINGS } from "../settings.js";
2
2
  const sendMetrics = async ({ apiKey, appId, payload }) => {
3
- await fetch(`${CORE_SETTINGS.domains.api}/metrics`, {
4
- method: 'POST',
5
- headers: {
6
- 'Content-Type': 'application/json',
7
- },
8
- body: JSON.stringify({ ...payload, appId, apiKey }),
9
- });
3
+ await fetch(`${CORE_SETTINGS.domains.api}/metrics`, {
4
+ method: "POST",
5
+ headers: {
6
+ "Content-Type": "application/json"
7
+ },
8
+ body: JSON.stringify({ ...payload, appId, apiKey })
9
+ });
10
+ };
11
+ var sendMetrics_default = sendMetrics;
12
+ export {
13
+ sendMetrics_default as default
10
14
  };
11
- export default sendMetrics;
@@ -0,0 +1,43 @@
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 buildPortalUrl_exports = {};
20
+ __export(buildPortalUrl_exports, {
21
+ default: () => buildPortalUrl_default
22
+ });
23
+ module.exports = __toCommonJS(buildPortalUrl_exports);
24
+ var import_settings = require("../settings.cjs");
25
+ const buildPortalUrl = async ({ access_token, redirectUrl }) => {
26
+ const response = await fetch(`${import_settings.CORE_SETTINGS.domains.api}/portal/exchange`, {
27
+ method: "GET",
28
+ headers: {
29
+ Authorization: `Bearer ${access_token}`
30
+ }
31
+ });
32
+ if (!response.ok) {
33
+ const error = await response.text();
34
+ throw new Error(error);
35
+ }
36
+ const body = await response.json();
37
+ const { code, redirectUrl: portalUrl } = body;
38
+ const url = new URL(portalUrl);
39
+ url.searchParams.set("code", code);
40
+ url.searchParams.set("redirectUrl", redirectUrl);
41
+ return url;
42
+ };
43
+ var buildPortalUrl_default = buildPortalUrl;
@@ -0,0 +1,9 @@
1
+ import * as url from 'url';
2
+
3
+ type BuildPortalUrlPayload = {
4
+ access_token: string;
5
+ redirectUrl: string;
6
+ };
7
+ declare const buildPortalUrl: ({ access_token, redirectUrl }: BuildPortalUrlPayload) => Promise<url.URL>;
8
+
9
+ export { buildPortalUrl as default };
@@ -1,6 +1,9 @@
1
+ import * as url from 'url';
2
+
1
3
  type BuildPortalUrlPayload = {
2
4
  access_token: string;
3
5
  redirectUrl: string;
4
6
  };
5
- declare const buildPortalUrl: ({ access_token, redirectUrl }: BuildPortalUrlPayload) => Promise<import("url").URL>;
6
- export default buildPortalUrl;
7
+ declare const buildPortalUrl: ({ access_token, redirectUrl }: BuildPortalUrlPayload) => Promise<url.URL>;
8
+
9
+ export { buildPortalUrl as default };
@@ -1,20 +1,23 @@
1
- import { CORE_SETTINGS } from '../settings.js';
1
+ import { CORE_SETTINGS } from "../settings.js";
2
2
  const buildPortalUrl = async ({ access_token, redirectUrl }) => {
3
- const response = await fetch(`${CORE_SETTINGS.domains.api}/portal/exchange`, {
4
- method: 'GET',
5
- headers: {
6
- Authorization: `Bearer ${access_token}`,
7
- },
8
- });
9
- if (!response.ok) {
10
- const error = await response.text();
11
- throw new Error(error);
3
+ const response = await fetch(`${CORE_SETTINGS.domains.api}/portal/exchange`, {
4
+ method: "GET",
5
+ headers: {
6
+ Authorization: `Bearer ${access_token}`
12
7
  }
13
- const body = await response.json();
14
- const { code, redirectUrl: portalUrl } = body;
15
- const url = new URL(portalUrl);
16
- url.searchParams.set('code', code);
17
- url.searchParams.set('redirectUrl', redirectUrl);
18
- return url;
8
+ });
9
+ if (!response.ok) {
10
+ const error = await response.text();
11
+ throw new Error(error);
12
+ }
13
+ const body = await response.json();
14
+ const { code, redirectUrl: portalUrl } = body;
15
+ const url = new URL(portalUrl);
16
+ url.searchParams.set("code", code);
17
+ url.searchParams.set("redirectUrl", redirectUrl);
18
+ return url;
19
+ };
20
+ var buildPortalUrl_default = buildPortalUrl;
21
+ export {
22
+ buildPortalUrl_default as default
19
23
  };
20
- export default buildPortalUrl;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var portal_exports = {};
30
+ __export(portal_exports, {
31
+ buildPortalUrl: () => import_buildPortalUrl.default
32
+ });
33
+ module.exports = __toCommonJS(portal_exports);
34
+ var import_buildPortalUrl = __toESM(require("./buildPortalUrl.cjs"), 1);
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ buildPortalUrl
38
+ });
@@ -0,0 +1,2 @@
1
+ export { default as buildPortalUrl } from './buildPortalUrl.cjs';
2
+ import 'url';
@@ -1 +1,2 @@
1
1
  export { default as buildPortalUrl } from './buildPortalUrl.js';
2
+ import 'url';
@@ -1 +1,4 @@
1
- export { default as buildPortalUrl } from './buildPortalUrl.js';
1
+ import { default as default2 } from "./buildPortalUrl.js";
2
+ export {
3
+ default2 as buildPortalUrl
4
+ };
@@ -0,0 +1,64 @@
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 settings_exports = {};
20
+ __export(settings_exports, {
21
+ CORE_SETTINGS: () => CORE_SETTINGS
22
+ });
23
+ module.exports = __toCommonJS(settings_exports);
24
+ const PROD_DOMAINS = {
25
+ api: "https://api.auditauth.com/v1",
26
+ client: "https://auditauth.com"
27
+ };
28
+ const LOCAL_DOMAINS = {
29
+ api: "http://localhost:4000/v1",
30
+ client: "http://localhost:3000"
31
+ };
32
+ const resolveImportMeta = () => {
33
+ try {
34
+ return Function(
35
+ 'return typeof import.meta !== "undefined" ? import.meta : undefined;'
36
+ )();
37
+ } catch {
38
+ return void 0;
39
+ }
40
+ };
41
+ const resolveSdkEnv = () => {
42
+ const importMeta = resolveImportMeta();
43
+ const importMetaEnv = importMeta?.env?.AUDITAUTH_SDK_ENV ?? importMeta?.env?.VITE_AUDITAUTH_SDK_ENV;
44
+ const globalEnv = typeof globalThis !== "undefined" ? globalThis.__AUDITAUTH_SDK_ENV__ : void 0;
45
+ const processEnv = typeof process !== "undefined" ? process.env?.AUDITAUTH_SDK_ENV ?? process.env?.NEXT_PUBLIC_AUDITAUTH_SDK_ENV ?? process.env?.NODE_ENV : void 0;
46
+ return (importMetaEnv ?? globalEnv ?? processEnv ?? "production").toLowerCase();
47
+ };
48
+ const isDevelopmentEnv = ["development", "dev", "local"].includes(resolveSdkEnv());
49
+ const CORE_SETTINGS = {
50
+ jwt_public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs2EYs4Q9OyjNuAEPqb4j\nIzc52JdfVcNvEbG43Xp8B2kI9QxwRyX7rtFSwKowj3W1BlCLaTIMK3TafWOf9QwH\nfemuL9Ni37PFcGptzpyuoCYYA650EuD82PENcO49lsObvty2cuXxQszbPPvAecm4\nJ/XG70td/W1UwbjAJcdmp8ktZGYR0JXM37hYA9Xq/aKwu7d0FTL6WdKTvt3L5VxL\nF6WNyLs65ZSbu+j8UEkwmoJ9h9Y0mLQmFtmkoh/HWOFyFDnBNiJX0vRb++RhJw6w\ncrSbqpbTu7z4vIep5lgSOut39P273SVTQZ3cGQIS+605Ur5wjkkSzzaJV1QLBBR9\nAQIDAQAB\n-----END PUBLIC KEY-----\n",
51
+ jwt_issuer: "https://api.auditauth.com",
52
+ domains: isDevelopmentEnv ? LOCAL_DOMAINS : PROD_DOMAINS,
53
+ storage_keys: {
54
+ access: "auditauth_access",
55
+ session: "auditauth_session",
56
+ refresh: "auditauth_refresh",
57
+ session_id: "auditauth_sid",
58
+ sync: "__auditauth_sync__"
59
+ }
60
+ };
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ CORE_SETTINGS
64
+ });
@@ -0,0 +1,20 @@
1
+ declare const CORE_SETTINGS: {
2
+ readonly jwt_public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs2EYs4Q9OyjNuAEPqb4j\nIzc52JdfVcNvEbG43Xp8B2kI9QxwRyX7rtFSwKowj3W1BlCLaTIMK3TafWOf9QwH\nfemuL9Ni37PFcGptzpyuoCYYA650EuD82PENcO49lsObvty2cuXxQszbPPvAecm4\nJ/XG70td/W1UwbjAJcdmp8ktZGYR0JXM37hYA9Xq/aKwu7d0FTL6WdKTvt3L5VxL\nF6WNyLs65ZSbu+j8UEkwmoJ9h9Y0mLQmFtmkoh/HWOFyFDnBNiJX0vRb++RhJw6w\ncrSbqpbTu7z4vIep5lgSOut39P273SVTQZ3cGQIS+605Ur5wjkkSzzaJV1QLBBR9\nAQIDAQAB\n-----END PUBLIC KEY-----\n";
3
+ readonly jwt_issuer: "https://api.auditauth.com";
4
+ readonly domains: {
5
+ readonly api: "http://localhost:4000/v1";
6
+ readonly client: "http://localhost:3000";
7
+ } | {
8
+ readonly api: "https://api.auditauth.com/v1";
9
+ readonly client: "https://auditauth.com";
10
+ };
11
+ readonly storage_keys: {
12
+ readonly access: "auditauth_access";
13
+ readonly session: "auditauth_session";
14
+ readonly refresh: "auditauth_refresh";
15
+ readonly session_id: "auditauth_sid";
16
+ readonly sync: "__auditauth_sync__";
17
+ };
18
+ };
19
+
20
+ export { CORE_SETTINGS };
@@ -2,11 +2,11 @@ declare const CORE_SETTINGS: {
2
2
  readonly jwt_public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs2EYs4Q9OyjNuAEPqb4j\nIzc52JdfVcNvEbG43Xp8B2kI9QxwRyX7rtFSwKowj3W1BlCLaTIMK3TafWOf9QwH\nfemuL9Ni37PFcGptzpyuoCYYA650EuD82PENcO49lsObvty2cuXxQszbPPvAecm4\nJ/XG70td/W1UwbjAJcdmp8ktZGYR0JXM37hYA9Xq/aKwu7d0FTL6WdKTvt3L5VxL\nF6WNyLs65ZSbu+j8UEkwmoJ9h9Y0mLQmFtmkoh/HWOFyFDnBNiJX0vRb++RhJw6w\ncrSbqpbTu7z4vIep5lgSOut39P273SVTQZ3cGQIS+605Ur5wjkkSzzaJV1QLBBR9\nAQIDAQAB\n-----END PUBLIC KEY-----\n";
3
3
  readonly jwt_issuer: "https://api.auditauth.com";
4
4
  readonly domains: {
5
- readonly api: "https://api.auditauth.com/v1";
6
- readonly client: "https://auditauth.com";
7
- } | {
8
5
  readonly api: "http://localhost:4000/v1";
9
6
  readonly client: "http://localhost:3000";
7
+ } | {
8
+ readonly api: "https://api.auditauth.com/v1";
9
+ readonly client: "https://auditauth.com";
10
10
  };
11
11
  readonly storage_keys: {
12
12
  readonly access: "auditauth_access";
@@ -16,4 +16,5 @@ declare const CORE_SETTINGS: {
16
16
  readonly sync: "__auditauth_sync__";
17
17
  };
18
18
  };
19
+
19
20
  export { CORE_SETTINGS };
package/dist/settings.js CHANGED
@@ -1,39 +1,40 @@
1
1
  const PROD_DOMAINS = {
2
- api: 'https://api.auditauth.com/v1',
3
- client: 'https://auditauth.com',
2
+ api: "https://api.auditauth.com/v1",
3
+ client: "https://auditauth.com"
4
4
  };
5
5
  const LOCAL_DOMAINS = {
6
- api: 'http://localhost:4000/v1',
7
- client: 'http://localhost:3000',
6
+ api: "http://localhost:4000/v1",
7
+ client: "http://localhost:3000"
8
+ };
9
+ const resolveImportMeta = () => {
10
+ try {
11
+ return Function(
12
+ 'return typeof import.meta !== "undefined" ? import.meta : undefined;'
13
+ )();
14
+ } catch {
15
+ return void 0;
16
+ }
8
17
  };
9
18
  const resolveSdkEnv = () => {
10
- const importMetaEnv = typeof import.meta !== 'undefined'
11
- ? (import.meta.env
12
- ?.AUDITAUTH_SDK_ENV ??
13
- import.meta.env
14
- ?.VITE_AUDITAUTH_SDK_ENV)
15
- : undefined;
16
- const globalEnv = typeof globalThis !== 'undefined'
17
- ? globalThis.__AUDITAUTH_SDK_ENV__
18
- : undefined;
19
- const processEnv = typeof process !== 'undefined'
20
- ? process.env?.AUDITAUTH_SDK_ENV ??
21
- process.env?.NEXT_PUBLIC_AUDITAUTH_SDK_ENV ??
22
- process.env?.NODE_ENV
23
- : undefined;
24
- return (importMetaEnv ?? globalEnv ?? processEnv ?? 'production').toLowerCase();
19
+ const importMeta = resolveImportMeta();
20
+ const importMetaEnv = importMeta?.env?.AUDITAUTH_SDK_ENV ?? importMeta?.env?.VITE_AUDITAUTH_SDK_ENV;
21
+ const globalEnv = typeof globalThis !== "undefined" ? globalThis.__AUDITAUTH_SDK_ENV__ : void 0;
22
+ const processEnv = typeof process !== "undefined" ? process.env?.AUDITAUTH_SDK_ENV ?? process.env?.NEXT_PUBLIC_AUDITAUTH_SDK_ENV ?? process.env?.NODE_ENV : void 0;
23
+ return (importMetaEnv ?? globalEnv ?? processEnv ?? "production").toLowerCase();
25
24
  };
26
- const isDevelopmentEnv = ['development', 'dev', 'local'].includes(resolveSdkEnv());
25
+ const isDevelopmentEnv = ["development", "dev", "local"].includes(resolveSdkEnv());
27
26
  const CORE_SETTINGS = {
28
- jwt_public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs2EYs4Q9OyjNuAEPqb4j\nIzc52JdfVcNvEbG43Xp8B2kI9QxwRyX7rtFSwKowj3W1BlCLaTIMK3TafWOf9QwH\nfemuL9Ni37PFcGptzpyuoCYYA650EuD82PENcO49lsObvty2cuXxQszbPPvAecm4\nJ/XG70td/W1UwbjAJcdmp8ktZGYR0JXM37hYA9Xq/aKwu7d0FTL6WdKTvt3L5VxL\nF6WNyLs65ZSbu+j8UEkwmoJ9h9Y0mLQmFtmkoh/HWOFyFDnBNiJX0vRb++RhJw6w\ncrSbqpbTu7z4vIep5lgSOut39P273SVTQZ3cGQIS+605Ur5wjkkSzzaJV1QLBBR9\nAQIDAQAB\n-----END PUBLIC KEY-----\n",
29
- jwt_issuer: "https://api.auditauth.com",
30
- domains: isDevelopmentEnv ? LOCAL_DOMAINS : PROD_DOMAINS,
31
- storage_keys: {
32
- access: 'auditauth_access',
33
- session: 'auditauth_session',
34
- refresh: 'auditauth_refresh',
35
- session_id: 'auditauth_sid',
36
- sync: '__auditauth_sync__',
37
- }
27
+ jwt_public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs2EYs4Q9OyjNuAEPqb4j\nIzc52JdfVcNvEbG43Xp8B2kI9QxwRyX7rtFSwKowj3W1BlCLaTIMK3TafWOf9QwH\nfemuL9Ni37PFcGptzpyuoCYYA650EuD82PENcO49lsObvty2cuXxQszbPPvAecm4\nJ/XG70td/W1UwbjAJcdmp8ktZGYR0JXM37hYA9Xq/aKwu7d0FTL6WdKTvt3L5VxL\nF6WNyLs65ZSbu+j8UEkwmoJ9h9Y0mLQmFtmkoh/HWOFyFDnBNiJX0vRb++RhJw6w\ncrSbqpbTu7z4vIep5lgSOut39P273SVTQZ3cGQIS+605Ur5wjkkSzzaJV1QLBBR9\nAQIDAQAB\n-----END PUBLIC KEY-----\n",
28
+ jwt_issuer: "https://api.auditauth.com",
29
+ domains: isDevelopmentEnv ? LOCAL_DOMAINS : PROD_DOMAINS,
30
+ storage_keys: {
31
+ access: "auditauth_access",
32
+ session: "auditauth_session",
33
+ refresh: "auditauth_refresh",
34
+ session_id: "auditauth_sid",
35
+ sync: "__auditauth_sync__"
36
+ }
37
+ };
38
+ export {
39
+ CORE_SETTINGS
38
40
  };
39
- export { CORE_SETTINGS };
package/dist/types.cjs ADDED
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,44 @@
1
+ type AuditAuthConfig = {
2
+ apiKey: string;
3
+ redirectUrl: string;
4
+ baseUrl: string;
5
+ appId: string;
6
+ };
7
+ type SessionUser = {
8
+ _id: string;
9
+ email: string;
10
+ email_verify: boolean;
11
+ name: string;
12
+ avatar: {
13
+ url: string | null;
14
+ format: string;
15
+ };
16
+ providers: string[];
17
+ };
18
+ type RequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
19
+ type Metric = {
20
+ event_type: 'request';
21
+ runtime: 'browser' | 'server';
22
+ target: {
23
+ type: 'api';
24
+ method: RequestMethod;
25
+ path: string;
26
+ status: number;
27
+ duration_ms: number;
28
+ };
29
+ } | {
30
+ event_type: 'navigation';
31
+ runtime: 'browser' | 'server';
32
+ target: {
33
+ type: 'page';
34
+ path: string;
35
+ };
36
+ };
37
+ type CredentialsResponse = {
38
+ access_token: string;
39
+ access_expires_seconds: number;
40
+ refresh_token: string;
41
+ refresh_expires_seconds: number;
42
+ };
43
+
44
+ export type { AuditAuthConfig, CredentialsResponse, Metric, RequestMethod, SessionUser };
package/dist/types.d.ts CHANGED
@@ -40,4 +40,5 @@ type CredentialsResponse = {
40
40
  refresh_token: string;
41
41
  refresh_expires_seconds: number;
42
42
  };
43
- export type { CredentialsResponse, AuditAuthConfig, SessionUser, Metric, RequestMethod };
43
+
44
+ export type { AuditAuthConfig, CredentialsResponse, Metric, RequestMethod, SessionUser };
package/dist/types.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auditauth/core",
3
- "version": "0.2.0-beta.2",
3
+ "version": "0.2.0-beta.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Nimibyte",
@@ -24,8 +24,9 @@
24
24
  "security",
25
25
  "auditauth"
26
26
  ],
27
- "main": "dist/index.js",
28
- "types": "dist/index.d.ts",
27
+ "main": "./dist/index.cjs",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
29
30
  "files": [
30
31
  "dist"
31
32
  ],
@@ -33,12 +34,16 @@
33
34
  "exports": {
34
35
  ".": {
35
36
  "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js",
38
+ "require": "./dist/index.cjs",
36
39
  "default": "./dist/index.js"
37
40
  },
38
41
  "./package.json": "./package.json"
39
42
  },
40
43
  "scripts": {
41
- "build": "tsc -p tsconfig.build.json",
42
- "dev": "tsc -p tsconfig.build.json --watch"
44
+ "build": "tsup && node ../../scripts/fix-cjs-relative-imports.mjs dist",
45
+ "dev": "tsup --watch",
46
+ "clean": "rm -rf dist",
47
+ "prepack": "npm run build"
43
48
  }
44
49
  }