@axinom/mosaic-user-auth-utils 0.8.1-rc.1 → 0.8.1-rc.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-user-auth-utils",
3
- "version": "0.8.1-rc.1",
3
+ "version": "0.8.1-rc.10",
4
4
  "description": "Shared types used by user-service for integration clients",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -10,7 +10,8 @@
10
10
  "axinom mosaic"
11
11
  ],
12
12
  "files": [
13
- "dist"
13
+ "dist",
14
+ "src"
14
15
  ],
15
16
  "main": "dist/index.js",
16
17
  "types": "dist/index.d.ts",
@@ -31,5 +32,5 @@
31
32
  "publishConfig": {
32
33
  "access": "public"
33
34
  },
34
- "gitHead": "2a0359d6b41b58dc05d2e0a3a1fa929c6712e251"
35
+ "gitHead": "3006785f98bc4177e940571365d4317c9c6e0f8e"
35
36
  }
@@ -0,0 +1,47 @@
1
+ import { IdpProtocol } from './enums';
2
+
3
+ export const managedIdProviderDefaults = {
4
+ AX_GOOGLE: {
5
+ discoveryDocumentUrl:
6
+ 'https://accounts.google.com/.well-known/openid-configuration',
7
+ providerIconUrl: 'https://developers.google.com/identity/images/g-logo.png',
8
+ additionalParams: {
9
+ access_type: 'offline',
10
+ },
11
+ scopes: [
12
+ { name: 'openid', default: true },
13
+ { name: 'email', default: true },
14
+ { name: 'profile', default: true },
15
+ ],
16
+ protocol: IdpProtocol.OIDC,
17
+ },
18
+ AX_FACEBOOK: {
19
+ authorizationEndpointUrl: 'https://www.facebook.com/dialog/oauth',
20
+ tokenEndpointUrl: 'https://graph.facebook.com/oauth/access_token',
21
+ userInfoEndpointUrl: 'https://graph.facebook.com/me',
22
+ scopes: [{ name: 'email', default: true }],
23
+ protocol: IdpProtocol.OAUTH2,
24
+ },
25
+ AX_APPLE: {
26
+ discoveryDocumentUrl:
27
+ 'https://appleid.apple.com/.well-known/openid-configuration',
28
+ additionalParams: {
29
+ response_mode: 'form_post',
30
+ },
31
+ scopes: [
32
+ { name: 'openid', default: true },
33
+ { name: 'email', default: true },
34
+ { name: 'name', default: true },
35
+ ],
36
+ protocol: IdpProtocol.OIDC,
37
+ },
38
+ AX_AUTH: {
39
+ scopes: [
40
+ { name: 'openid', default: true },
41
+ { name: 'email', default: true },
42
+ { name: 'profile', default: true },
43
+ { name: 'offline_access', default: true },
44
+ ],
45
+ protocol: IdpProtocol.OIDC,
46
+ },
47
+ };
@@ -0,0 +1,126 @@
1
+ /**
2
+ * This is the Error Type that the REST middleware will respond when there's an error
3
+ * from the User Service that does not belong to Token/SignOut or IDPConfiguration responses.
4
+ */
5
+ export enum UserAuthErrorCode {
6
+ AUTH_FLOW_ERROR = 'AUTH_FLOW_ERROR',
7
+ IDP_CONFIGURATION_ERROR = 'IDP_CONFIGURATION_ERROR',
8
+ BAD_REQUEST = 'BAD_REQUEST',
9
+ ACCOUNT_NOT_ACTIVE = 'ACCOUNT_NOT_ACTIVE',
10
+ INVALID_USER = 'INVALID_USER',
11
+ INVALID_APPLICATION = 'INVALID_APPLICATION',
12
+ APPLICATION_NOT_ACTIVE = 'APPLICATION_NOT_ACTIVE',
13
+ INVALID_IDP_CONNECTION = 'INVALID_IDP_CONNECTION',
14
+ INTERNAL_SERVER_ERROR = 'INTERNAL_SERVER_ERROR',
15
+ }
16
+
17
+ /**
18
+ * Token response code from User Service Auth API
19
+ */
20
+ export enum TokenResponseCode {
21
+ SUCCESS = 'SUCCESS',
22
+ NEEDS_LOGIN = 'NEEDS_LOGIN',
23
+ USER_NOT_FOUND = 'USER_NOT_FOUND',
24
+ ACCOUNT_NOT_ACTIVE = 'ACCOUNT_NOT_ACTIVE',
25
+ AUTH_FLOW_ERROR = 'AUTH_FLOW_ERROR',
26
+ BAD_REQUEST = 'BAD_REQUEST',
27
+ INTERNAL_SERVER_ERROR = 'INTERNAL_SERVER_ERROR',
28
+ }
29
+
30
+ /**
31
+ * Sign out response code from User Service Auth API
32
+ */
33
+ export enum SignOutResponseCode {
34
+ SUCCESS = 'SUCCESS',
35
+ BAD_REQUEST = 'BAD_REQUEST',
36
+ INTERNAL_SERVER_ERROR = 'INTERNAL_SERVER_ERROR',
37
+ }
38
+
39
+ /**
40
+ * IDP Configuration response code from User Service Auth API
41
+ */
42
+ export enum IdpConfigurationResponseCode {
43
+ SUCCESS = 'SUCCESS',
44
+ APPLICATION_NOT_ACTIVE = 'APPLICATION_NOT_ACTIVE',
45
+ NO_ACTIVE_IDPS = 'NO_ACTIVE_IDPS',
46
+ ACCOUNT_NOT_ACTIVE = 'ACCOUNT_NOT_ACTIVE',
47
+ BAD_REQUEST = 'BAD_REQUEST',
48
+ INTERNAL_SERVER_ERROR = 'INTERNAL_SERVER_ERROR',
49
+ }
50
+
51
+ /**
52
+ * Sign In With Credentials Response Code from User Service Auth API
53
+ */
54
+ export enum SignInResponseCode {
55
+ SUCCESS = 'SUCCESS',
56
+ INTERNAL_SERVER_ERROR = 'INTERNAL_SERVER_ERROR',
57
+ AUTH_FLOW_ERROR = 'AUTH_FLOW_ERROR',
58
+ INVALID_CREDENTIALS = 'INVALID_CREDENTIALS',
59
+ SERVICE_CONFIGURATION_ERROR = 'SERVICE_CONFIGURATION_ERROR',
60
+ INVALID_IDP_CONNECTION = 'INVALID_IDP_CONNECTION',
61
+ APPLICATION_NOT_ACTIVE = 'APPLICATION_NOT_ACTIVE',
62
+ }
63
+
64
+ /**
65
+ * Sign In With Credentials Password Reset/Complete Password Reset Code from User Service Auth API
66
+ */
67
+ export enum ResetPasswordResponseCode {
68
+ SUCCESS = 'SUCCESS',
69
+ ERROR = 'ERROR',
70
+ SERVICE_CONFIGURATION_ERROR = 'SERVICE_CONFIGURATION_ERROR',
71
+ }
72
+
73
+ /**
74
+ * Sign Up With Credential Response Code from User Service Auth API
75
+ */
76
+ export enum UserSignUpResponseCode {
77
+ SUCCESS = 'SUCCESS',
78
+ ERROR = 'ERROR',
79
+ SERVICE_CONFIGURATION_ERROR = 'SERVICE_CONFIGURATION_ERROR',
80
+ }
81
+
82
+ /**
83
+ * Verify Sign Up With Credential Response Code from User Service Auth API
84
+ */
85
+ export enum CompleteUserSignUpResponseCode {
86
+ SUCCESS = 'SUCCESS',
87
+ ERROR = 'ERROR',
88
+ SERVICE_CONFIGURATION_ERROR = 'SERVICE_CONFIGURATION_ERROR',
89
+ }
90
+
91
+ /**
92
+ * OTP Check Response Code from User Service Auth API
93
+ * This response type is used for both Sign Up OTP check and Reset Password OTP check.
94
+ */
95
+ export enum CheckOtpResponseCode {
96
+ SUCCESS = 'SUCCESS',
97
+ ERROR = 'ERROR',
98
+ SERVICE_CONFIGURATION_ERROR = 'SERVICE_CONFIGURATION_ERROR',
99
+ }
100
+
101
+ /**
102
+ * IDP Protocol categories
103
+ */
104
+ export enum IdpProtocol {
105
+ OIDC = 'OIDC',
106
+ OAUTH2 = 'OAUTH2',
107
+ DELEGATED = 'DELEGATED',
108
+ }
109
+
110
+ /**
111
+ * Response codes specific to Native Cookie Decryption.
112
+ */
113
+ export enum DecryptNativeCookieResponseCode {
114
+ SUCCESS = 'SUCCESS',
115
+ COOKIE_DECRYPTION_FAILED = 'COOKIE_DECRYPTION_FAILED',
116
+ }
117
+
118
+ /**
119
+ * Response codes specific to End User Application Token Generation
120
+ */
121
+ export enum AuthenticateEndUserApplicationResponseCode {
122
+ SUCCESS = 'SUCCESS',
123
+ APPLICATION_NOT_FOUND = 'APPLICATION_NOT_FOUND',
124
+ APPLICATION_NOT_ENABLED = 'APPLICATION_NOT_ENABLED',
125
+ END_USER_APP_TOKEN_GENERATION_ERROR = 'END_USER_APP_TOKEN_GENERATION_ERROR',
126
+ }
@@ -0,0 +1,159 @@
1
+ import {
2
+ CheckOtpResponseCode,
3
+ CompleteUserSignUpResponseCode,
4
+ DecryptNativeCookieResponseCode,
5
+ IdpConfigurationResponseCode,
6
+ ResetPasswordResponseCode,
7
+ SignInResponseCode,
8
+ SignOutResponseCode,
9
+ TokenResponseCode,
10
+ UserSignUpResponseCode,
11
+ } from './enums';
12
+
13
+ /**
14
+ * Represents a user token
15
+ */
16
+ export interface UserToken {
17
+ accessToken: string;
18
+ expiresInSeconds: number;
19
+ expiresAt: Date;
20
+ }
21
+
22
+ /**
23
+ * Represents an authenticated user
24
+ */
25
+ export interface User {
26
+ id: string;
27
+ name: string | null;
28
+ email: string | null;
29
+ profileId: string;
30
+ token: UserToken;
31
+ }
32
+
33
+ /**
34
+ * Token response from User Service Auth API
35
+ */
36
+ export interface TokenResponse {
37
+ code: TokenResponseCode;
38
+ message?: string;
39
+ tenantId?: string;
40
+ environmentId?: string;
41
+ applicationId?: string;
42
+ extensions?: unknown;
43
+ user?: User;
44
+ }
45
+
46
+ /**
47
+ * Sign out response from User Service Auth API
48
+ */
49
+ export interface SignOutResponse {
50
+ code: SignOutResponseCode;
51
+ message?: string;
52
+ }
53
+
54
+ /**
55
+ * Represents an IDP Configuration
56
+ */
57
+ export interface IdpConfiguration {
58
+ idpConnectionId: string;
59
+ providerId: string;
60
+ clientId: string;
61
+ providerIconUrl: string | null;
62
+ title: string;
63
+ sortOrder: number | null;
64
+ }
65
+
66
+ /**
67
+ * IDP Configuration response from User Service Auth API
68
+ */
69
+ export interface IdpConfigurationResponse {
70
+ code: IdpConfigurationResponseCode;
71
+ message?: string;
72
+ tenantId?: string;
73
+ environmentId?: string;
74
+ applicationId?: string;
75
+ availableIdentityProviders?: IdpConfiguration[];
76
+ }
77
+
78
+ /**
79
+ * The well known endpoints exposed by ax-user-service.
80
+ */
81
+ export interface WellKnownEndpointResponse {
82
+ jwks: string;
83
+ userServiceAdminGQL: string;
84
+ userServiceEndUserGQL: string;
85
+ axAuthManagementGQL: string;
86
+ axAuthEndpoint: string;
87
+ }
88
+
89
+ /**
90
+ * Response for a SignInWithCredentials flow.
91
+ */
92
+ export interface SignInResponse {
93
+ code: SignInResponseCode;
94
+ message?: string;
95
+ details?: Record<string, unknown>;
96
+ }
97
+
98
+ /**
99
+ * Represents the response for a User Sign Up request.
100
+ */
101
+ export interface UserSignUpResponse {
102
+ code: UserSignUpResponseCode;
103
+ idpUserId?: string;
104
+ message?: string;
105
+ }
106
+
107
+ /**
108
+ * Represents the response for a Complete User Sign Up request.
109
+ */
110
+ export interface CompleteUserSignUpResponse {
111
+ code: CompleteUserSignUpResponseCode;
112
+ idpUserId?: string;
113
+ message?: string;
114
+ }
115
+
116
+ /**
117
+ * Represents the response for InitiatePasswordReset request.
118
+ */
119
+ export interface InitiatePasswordResetResponse {
120
+ code: ResetPasswordResponseCode;
121
+ message?: string;
122
+ details?: Record<string, unknown>;
123
+ }
124
+
125
+ /**
126
+ * Represents the response for a CompletePasswordReset request.
127
+ */
128
+ export interface CompletePasswordResetResponse {
129
+ code: ResetPasswordResponseCode;
130
+ message?: string;
131
+ details?: Record<string, unknown>;
132
+ }
133
+
134
+ /**
135
+ * Represents the response for a Check Password Reset OTP Request
136
+ */
137
+ export interface CheckPasswordResetOtpResponse {
138
+ code: CheckOtpResponseCode;
139
+ message?: string;
140
+ isOtpValid?: boolean;
141
+ }
142
+
143
+ /**
144
+ * Represents the response for a User Sign Up OTP Request
145
+ */
146
+ export interface CheckUserSignUpOtpResponse {
147
+ code: CheckOtpResponseCode;
148
+ message?: string;
149
+ isOtpValid?: boolean;
150
+ }
151
+
152
+ /**
153
+ * Represents the response for a Native Cookie Decrypt Response
154
+ */
155
+ export interface DecryptNativeCookieResponse {
156
+ code: DecryptNativeCookieResponseCode;
157
+ message?: string;
158
+ decryptedCookie?: string;
159
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './common/constants';
2
+ export * from './common/enums';
3
+ export * from './common/types';