@nibssplc/cams-sdk 0.0.1-beta.24 → 0.0.1-beta.26

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.
@@ -1,8 +1,8 @@
1
- import { CAMSConfig, CAMSTokenResponse, CAMSError } from "./types";
2
- import { Profile } from "./validators";
1
+ import { CAMSConfig, CAMSError } from "./types";
2
+ import { AuthFailureMessage, Profile } from "./validators";
3
3
  export interface CAMSEvents {
4
4
  onAuthStart?: () => void;
5
- onAuthSuccess?: (token: CAMSTokenResponse) => void;
5
+ onAuthSuccess?: (profile: Profile) => void;
6
6
  onAuthError?: (error: CAMSError) => void;
7
7
  onTokenExpired?: () => void;
8
8
  }
@@ -11,12 +11,13 @@ export declare class CAMSSessionManager {
11
11
  private readonly keyPrefix;
12
12
  private readonly events;
13
13
  private token;
14
+ private profile;
14
15
  constructor(storage?: StorageLike | null, keyPrefix?: string, events?: CAMSEvents);
15
16
  setItem(key: string, value: string): void;
16
17
  getItem(key: string): string | null;
17
18
  removeItem(key: string): void;
18
19
  clear(): void;
19
- login(config: CAMSConfig): Promise<CAMSTokenResponse>;
20
+ login(config: CAMSConfig): Promise<Profile>;
20
21
  logout(): Promise<void>;
21
22
  setToken(token: string): void;
22
23
  getAccessToken(): string | null;
@@ -27,6 +28,7 @@ export declare class CAMSSessionManager {
27
28
  isAuthenticated(): boolean;
28
29
  private decodeBase64Url;
29
30
  getProfile(): Promise<Profile | null>;
31
+ getSessionError(): AuthFailureMessage | null;
30
32
  }
31
33
  interface StorageLike {
32
34
  getItem(key: string): string | null;
package/dist/types.d.ts CHANGED
@@ -16,15 +16,9 @@ export declare enum CAMSErrorType {
16
16
  USER_CANCELLED = "USER_CANCELLED",
17
17
  INVALID_URL = "INVALID_URL",
18
18
  MAX_RETRIES_EXCEEDED = "MAX_RETRIES_EXCEEDED",
19
- API_VALIDATION_ERROR = "API_VALIDATION_ERROR"
19
+ API_VALIDATION_ERROR = "VALIDATION_ERROR"
20
20
  }
21
21
  export declare class CAMSError extends Error {
22
22
  type: CAMSErrorType;
23
23
  constructor(type: CAMSErrorType, message: string);
24
24
  }
25
- export interface CAMSTokenResponse {
26
- token: string;
27
- }
28
- export interface CAMSErrorResponse {
29
- error: string;
30
- }
@@ -1,21 +1,25 @@
1
1
  import { z } from "zod";
2
- export declare const TokenMessageSchema: z.ZodObject<{
2
+ export declare const ProfileSchema: z.ZodObject<{
3
3
  type: z.ZodLiteral<"AUTH_SUCCESS">;
4
- accessToken: z.ZodString;
5
- user: z.ZodOptional<z.ZodObject<{
4
+ userProfile: z.ZodObject<{
6
5
  name: z.ZodString;
7
6
  email: z.ZodEmail;
8
7
  mfaIsEnabled: z.ZodBoolean;
9
8
  message: z.ZodString;
10
- status: z.ZodBoolean;
11
- redirectURL: z.ZodURL;
9
+ isAuthenticated: z.ZodBoolean;
10
+ userType: z.ZodEnum<{
11
+ SUPER_ADMIN: "SUPER_ADMIN";
12
+ ADMIN: "ADMIN";
13
+ USER: "USER";
14
+ }>;
15
+ redirectURL: z.ZodOptional<z.ZodURL>;
12
16
  tokens: z.ZodObject<{
13
17
  Nonce: z.ZodString;
14
18
  Bearer: z.ZodString;
15
19
  }, z.core.$strip>;
16
- }, z.core.$strip>>;
20
+ }, z.core.$strip>;
17
21
  }, z.core.$strip>;
18
- export type TokenMessage = z.infer<typeof TokenMessageSchema>;
22
+ export type Profile = z.infer<typeof ProfileSchema>;
19
23
  export declare const ErrorMessageSchema: z.ZodObject<{
20
24
  error: z.ZodString;
21
25
  }, z.core.$strip>;
@@ -26,21 +30,4 @@ export declare const AuthFailureMessageSchema: z.ZodObject<{
26
30
  errorDetails: z.ZodUnion<[z.ZodObject<{}, z.core.$strip>, z.ZodAny]>;
27
31
  }, z.core.$strip>;
28
32
  export type AuthFailureMessage = z.infer<typeof AuthFailureMessageSchema>;
29
- export declare const TokenSchema: z.ZodObject<{
30
- access_token: z.ZodString;
31
- refresh_token: z.ZodOptional<z.ZodString>;
32
- expires_in: z.ZodNumber;
33
- token_type: z.ZodDefault<z.ZodString>;
34
- id_token: z.ZodOptional<z.ZodString>;
35
- }, z.core.$strip>;
36
- export type Token = z.infer<typeof TokenSchema>;
37
- export declare const ProfileSchema: z.ZodObject<{
38
- sub: z.ZodString;
39
- name: z.ZodOptional<z.ZodString>;
40
- email: z.ZodOptional<z.ZodEmail>;
41
- given_name: z.ZodOptional<z.ZodString>;
42
- family_name: z.ZodOptional<z.ZodString>;
43
- roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
44
- }, z.core.$strip>;
45
- export type Profile = z.infer<typeof ProfileSchema>;
46
33
  export declare const URLSchema: z.ZodURL;
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@nibssplc/cams-sdk",
3
- "version": "0.0.1-beta.24",
3
+ "version": "0.0.1-beta.26",
4
+ "workspaces": [
5
+ "packages/*"
6
+ ],
4
7
  "description": "Central Authentication Management Service (CAMS) SDK for popup-based authentication with Azure AD + custom 2FA",
5
8
  "main": "dist/index.cjs.js",
6
9
  "module": "dist/index.esm.js",
@@ -15,11 +18,14 @@
15
18
  }
16
19
  },
17
20
  "scripts": {
18
- "clean": "rm -rf dist",
21
+ "clean": "rm -rf dist || true",
19
22
  "build": "npx rollup -c",
20
23
  "prepare": "npm run clean && npm run build",
21
24
  "lint": "eslint src --ext .ts",
22
25
  "test": "npx jest --verbose",
26
+ "build:react": "cd packages/react && npm run build",
27
+ "test:react": "cd packages/react && npm run test",
28
+ "publish:all": "./scripts/publish.sh",
23
29
  "postpublish": "echo '✅ Published $(npm pkg get name)@$(npm pkg get version)'"
24
30
  },
25
31
  "keywords": [