@axinom/mosaic-user-auth 0.26.0-rc.2 → 0.26.0-rc.21
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/dist/UserServiceClient/UserServiceClient.d.ts +1 -1
- package/dist/UserServiceClient/UserServiceClient.d.ts.map +1 -1
- package/dist/common/ensure-error.d.ts.map +1 -1
- package/dist/common/stringify-gql-query.d.ts.map +1 -1
- package/dist/generated/ax-auth-management-graphql.types.d.ts +6 -18
- package/dist/generated/ax-auth-management-graphql.types.d.ts.map +1 -1
- package/dist/generated/user-service-end-user-graphql.types.d.ts +6 -18
- package/dist/generated/user-service-end-user-graphql.types.d.ts.map +1 -1
- package/dist/generated/user-service-management-graphql.types.d.ts +2 -6
- package/dist/generated/user-service-management-graphql.types.d.ts.map +1 -1
- package/dist/index.es.js +78 -28
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +78 -28
- package/dist/index.js.map +1 -1
- package/dist/util/endUserApplication.d.ts +1 -1
- package/dist/util/endUserApplication.d.ts.map +1 -1
- package/dist/util/userAuth.d.ts.map +1 -1
- package/dist/util/userProfile.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/util/endUserApplication.spec.ts +4 -3
- package/src/util/endUserApplication.ts +1 -1
- package/src/util/userAuth.spec.ts +6 -10
- package/src/util/userProfile.spec.ts +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthenticateEndUserApplicationResponse } from 'common/types';
|
|
1
|
+
import { AuthenticateEndUserApplicationResponse } from '../common/types';
|
|
2
2
|
import { AuthenticateEndUserApplicationInput } from '../generated/user-service-management-graphql.types';
|
|
3
3
|
/**
|
|
4
4
|
* Authenticate an End-User Application and receive a token.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endUserApplication.d.ts","sourceRoot":"","sources":["../../src/util/endUserApplication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"endUserApplication.d.ts","sourceRoot":"","sources":["../../src/util/endUserApplication.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sCAAsC,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAEL,mCAAmC,EAEpC,MAAM,oDAAoD,CAAC;AAE5D;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,GACzC,qCAAqC,mCAAmC,EACxE,8BAA8B,MAAM,KACnC,OAAO,CAAC,sCAAsC,CA6ChD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userAuth.d.ts","sourceRoot":"","sources":["../../src/util/userAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,6BAA6B,EAC7B,0BAA0B,EAC1B,6BAA6B,EAC7B,0BAA0B,EAE1B,2BAA2B,EAE3B,gBAAgB,EAGhB,6BAA6B,EAE7B,cAAc,EAKd,kBAAkB,EAElB,yBAAyB,EAC1B,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EACL,iCAAiC,EAEjC,0BAA0B,EAK1B,iCAAiC,EAGjC,0BAA0B,EAK1B,0BAA0B,EAE3B,MAAM,+CAA+C,CAAC;AAgCvD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"userAuth.d.ts","sourceRoot":"","sources":["../../src/util/userAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,6BAA6B,EAC7B,0BAA0B,EAC1B,6BAA6B,EAC7B,0BAA0B,EAE1B,2BAA2B,EAE3B,gBAAgB,EAGhB,6BAA6B,EAE7B,cAAc,EAKd,kBAAkB,EAElB,yBAAyB,EAC1B,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,EACL,iCAAiC,EAEjC,0BAA0B,EAK1B,iCAAiC,EAGjC,0BAA0B,E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,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,gBAAgB,cAAc,EAC9B,iBAAiB,MAAM,EACvB,WAAW,MAAM,KAChB,GASF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAC3B,gBAAgB,cAAc,EAC9B,iBAAiB,MAAM,EACvB,WAAW,MAAM,EACjB,eAAe,MAAM,KACpB,GAMF,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,gBAAgB,cAAc,KAC7B,OAAO,CAAC,SAAS,CA8BnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,gBAAgB,cAAc,KAC7B,OAAO,CAAC,SAAS,CAgBnB,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,gBAAgB,cAAc,KAC7B,OAAO,CAAC,OAAO,CAQjB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,iBAAiB,MAAM,EACvB,KAAK,MAAM,EACX,+BAA+B,MAAM,KACpC,OAAO,CAAC,2BAA2B,CAiCrC,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAO,IAEvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userProfile.d.ts","sourceRoot":"","sources":["../../src/util/userProfile.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AAezB,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"userProfile.d.ts","sourceRoot":"","sources":["../../src/util/userProfile.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AAezB,eAAO,MAAM,gBAAgB,GAC3B,oBAAoB,MAAM,EAC1B,aAAa,MAAM,EACnB,WAAW,MAAM,KAChB,OAAO,CAAC,2BAA2B,CA6BrC,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,oBAAoB,MAAM,EAC1B,aAAa,MAAM,EACnB,WAAW,MAAM,KAChB,OAAO,CAAC,mBAAmB,CA8B7B,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,oBAAoB,MAAM,EAC1B,aAAa,MAAM,KAClB,OAAO,CAAC,oBAAoB,CA0B9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,oBAAoB,MAAM,EAC1B,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,mBAAmB,MAAM,KACxB,OAAO,CAAC,yBAAyB,CAoCnC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,oBAAoB,MAAM,EAC1B,aAAa,MAAM,EACnB,qBAAqB,sBAAsB,KAC1C,OAAO,CAAC,yBAAyB,CAwCnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,oBAAoB,MAAM,EAC1B,aAAa,MAAM,EACnB,eAAe,MAAM,KACpB,OAAO,CAAC,yBAAyB,CAiCnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-user-auth",
|
|
3
|
-
"version": "0.26.0-rc.
|
|
3
|
+
"version": "0.26.0-rc.21",
|
|
4
4
|
"description": "Integration utilities from user-service for application frontends",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"build": "yarn clean && rollup -c",
|
|
22
22
|
"build:ci": "yarn workspaces focus && yarn build",
|
|
23
23
|
"dev": "rollup -c -w",
|
|
24
|
-
"test": "
|
|
24
|
+
"test": "vitest run",
|
|
25
25
|
"codegen": "graphql-codegen -r dotenv/config --config codegen.yml",
|
|
26
26
|
"lint": "eslint . --ext .ts,.tsx,.js --color --cache",
|
|
27
|
-
"test:ci": "
|
|
27
|
+
"test:ci": "vitest run --coverage"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@axinom/mosaic-user-auth-utils": "^0.8.
|
|
30
|
+
"@axinom/mosaic-user-auth-utils": "^0.8.28-rc.13",
|
|
31
31
|
"graphql-tag": "^2.11.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"@types/react-dom": "^17",
|
|
40
40
|
"@types/react-router-dom": "^5.3.3",
|
|
41
41
|
"graphql": "^15.4.0",
|
|
42
|
-
"jest": "^29",
|
|
43
42
|
"postcss": "^8.4.4",
|
|
44
43
|
"react": "^17.0.2",
|
|
45
44
|
"react-dom": "^17.0.2",
|
|
@@ -52,7 +51,8 @@
|
|
|
52
51
|
"rollup-plugin-terser": "^7.0.2",
|
|
53
52
|
"rollup-plugin-typescript2": "^0.29.0",
|
|
54
53
|
"ts-node": "^10.9.1",
|
|
55
|
-
"typescript": "^5.
|
|
54
|
+
"typescript": "^5.9.3",
|
|
55
|
+
"vitest": "^4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"react": "^17.0.2",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "2e005533c6167e6da226c57ccb43e07466831f01"
|
|
66
66
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AuthenticateEndUserApplicationResponseCode } from '@axinom/mosaic-user-auth-utils';
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { stringifyGqlQuery } from '../common/stringify-gql-query';
|
|
2
4
|
import {
|
|
3
5
|
AuthenticateEndUserApplicationResponse,
|
|
4
6
|
EndUserApplicationToken,
|
|
5
|
-
} from '
|
|
6
|
-
import { stringifyGqlQuery } from '../common/stringify-gql-query';
|
|
7
|
+
} from '../common/types';
|
|
7
8
|
import {
|
|
8
9
|
AuthenticateEndUserApplicationDocument,
|
|
9
10
|
AuthenticateEndUserApplicationInput,
|
|
@@ -15,7 +16,7 @@ describe('authenticateEndUserApplication', () => {
|
|
|
15
16
|
const fetchRef = global.fetch;
|
|
16
17
|
|
|
17
18
|
function mockFetchResponse<T>(response: T): void {
|
|
18
|
-
global.fetch =
|
|
19
|
+
global.fetch = vi.fn().mockImplementation(() =>
|
|
19
20
|
Promise.resolve({
|
|
20
21
|
json: () => Promise.resolve(response),
|
|
21
22
|
}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthenticateEndUserApplicationResponseCode } from '@axinom/mosaic-user-auth-utils';
|
|
2
|
-
import { AuthenticateEndUserApplicationResponse } from 'common/types';
|
|
3
2
|
import { stringifyGqlQuery } from '../common/stringify-gql-query';
|
|
3
|
+
import { AuthenticateEndUserApplicationResponse } from '../common/types';
|
|
4
4
|
import {
|
|
5
5
|
AuthenticateEndUserApplicationDocument,
|
|
6
6
|
AuthenticateEndUserApplicationInput,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
UserSignUpResponseCode,
|
|
20
20
|
WellKnownEndpointResponse,
|
|
21
21
|
} from '@axinom/mosaic-user-auth-utils';
|
|
22
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
22
23
|
import { stringifyGqlQuery } from '../common/stringify-gql-query';
|
|
23
24
|
import { SignInRequest, UserAuthConfig } from '../common/types';
|
|
24
25
|
import {
|
|
@@ -44,7 +45,6 @@ import {
|
|
|
44
45
|
DecryptNativeCookieDocument,
|
|
45
46
|
DecryptNativeCookieMutationVariables,
|
|
46
47
|
} from '../generated/user-service-management-graphql.types';
|
|
47
|
-
import * as userAuth from './userAuth';
|
|
48
48
|
import {
|
|
49
49
|
checkPasswordResetOtp,
|
|
50
50
|
checkUserSignUpOtp,
|
|
@@ -72,7 +72,7 @@ describe('user-auth', () => {
|
|
|
72
72
|
const fetchRef = global.fetch;
|
|
73
73
|
|
|
74
74
|
function mockFetchResponse<T>(response: T): void {
|
|
75
|
-
global.fetch =
|
|
75
|
+
global.fetch = vi.fn().mockImplementation(() =>
|
|
76
76
|
Promise.resolve({
|
|
77
77
|
json: () => Promise.resolve(response),
|
|
78
78
|
}),
|
|
@@ -164,11 +164,8 @@ describe('user-auth', () => {
|
|
|
164
164
|
},
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
-
const fetchUserTokenSpy = jest.spyOn(userAuth, 'fetchUserToken');
|
|
168
|
-
|
|
169
167
|
afterEach(() => {
|
|
170
168
|
resetCurrentUerToken();
|
|
171
|
-
fetchUserTokenSpy.mockClear();
|
|
172
169
|
});
|
|
173
170
|
|
|
174
171
|
it('should return a user token', async () => {
|
|
@@ -201,8 +198,8 @@ describe('user-auth', () => {
|
|
|
201
198
|
const token2 = await getUserToken(userAuthConfig);
|
|
202
199
|
|
|
203
200
|
expect(token1).toEqual(token2);
|
|
204
|
-
//
|
|
205
|
-
expect(
|
|
201
|
+
// fetch is called only once (second call used cache)
|
|
202
|
+
expect(global.fetch).toHaveBeenCalledTimes(1);
|
|
206
203
|
});
|
|
207
204
|
|
|
208
205
|
it('When the token is expired, a new token should be returned', async () => {
|
|
@@ -210,7 +207,6 @@ describe('user-auth', () => {
|
|
|
210
207
|
mockResponse.user!.token.expiresAt = new Date(Date.now());
|
|
211
208
|
|
|
212
209
|
mockFetchResponse<TokenResponse>(mockResponse);
|
|
213
|
-
const fetchUserTokenSpy = jest.spyOn(userAuth, 'fetchUserToken');
|
|
214
210
|
|
|
215
211
|
// make the 1st call
|
|
216
212
|
await getUserToken(userAuthConfig);
|
|
@@ -218,8 +214,8 @@ describe('user-auth', () => {
|
|
|
218
214
|
// make the second call
|
|
219
215
|
await getUserToken(userAuthConfig);
|
|
220
216
|
|
|
221
|
-
//
|
|
222
|
-
expect(
|
|
217
|
+
// fetch is called twice (token was expired, so it was re-fetched)
|
|
218
|
+
expect(global.fetch).toHaveBeenCalledTimes(2);
|
|
223
219
|
});
|
|
224
220
|
});
|
|
225
221
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { UserProfile } from '../common/types';
|
|
2
3
|
import {
|
|
3
4
|
createUserProfile,
|
|
@@ -14,7 +15,7 @@ describe('user-profile', () => {
|
|
|
14
15
|
const accessToken = 'ACCESS_TOKEN';
|
|
15
16
|
|
|
16
17
|
function mockFetchResponse(responseData: Record<string, unknown>): void {
|
|
17
|
-
global.fetch =
|
|
18
|
+
global.fetch = vi.fn().mockImplementation(() =>
|
|
18
19
|
Promise.resolve({
|
|
19
20
|
json: () =>
|
|
20
21
|
Promise.resolve({
|