@axinom/mosaic-user-auth 0.3.8-rc.5 → 0.4.0
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/CHANGELOG.md +10 -0
- package/dist/UserServiceClient/UserServiceClient.d.ts +13 -13
- package/dist/UserServiceClient/UserServiceClient.d.ts.map +1 -1
- package/dist/common/types.d.ts +56 -2
- package/dist/common/types.d.ts.map +1 -1
- package/dist/generated/user-service-consumer-graphql.types.d.ts +6 -6
- package/dist/generated/user-service-consumer-graphql.types.d.ts.map +1 -1
- package/dist/generated/user-service-management-graphql.types.d.ts +21 -1
- package/dist/generated/user-service-management-graphql.types.d.ts.map +1 -1
- package/dist/index.es.js +148 -69
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +148 -69
- package/dist/index.js.map +1 -1
- package/dist/util/userAuth.d.ts.map +1 -1
- package/dist/util/userProfile.d.ts +7 -7
- package/dist/util/userProfile.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -1634,9 +1634,6 @@ const InitiateConsumerPasswordResetDocument = { "kind": "Document", "definitions
|
|
|
1634
1634
|
const CheckPasswordResetOtpDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CheckPasswordResetOtp" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "CheckConsumerPasswordResetOtpInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "checkConsumerPasswordResetOtp" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "isOtpValid" }, "arguments": [], "directives": [] }] } }] } }] };
|
|
1635
1635
|
const CompleteConsumerPasswordResetDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CompleteConsumerPasswordReset" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "CompleteConsumerPasswordResetInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "completeConsumerPasswordReset" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "idpUserId" }, "arguments": [], "directives": [] }] } }] } }] };
|
|
1636
1636
|
|
|
1637
|
-
// A valid user token is cached in order to reduce unnecessary calls to the User Auth API
|
|
1638
|
-
// It is nullified just before the expiry so that the next call to `getUserToken` will retrieve a new token
|
|
1639
|
-
let currentUserToken = null;
|
|
1640
1637
|
function invokeUserAuthMethod(method, userAuthConfig, isRootLevel = false) {
|
|
1641
1638
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1642
1639
|
const endpointUrl = new URL(`${userAuthConfig.tenantId}/${userAuthConfig.environmentId}/${userAuthConfig.applicationId}/${method}`, userAuthConfig.userAuthBaseUrl);
|
|
@@ -1952,21 +1949,6 @@ const fetchUserToken = (userAuthConfig) => __awaiter(void 0, void 0, void 0, fun
|
|
|
1952
1949
|
};
|
|
1953
1950
|
}
|
|
1954
1951
|
});
|
|
1955
|
-
/**
|
|
1956
|
-
* Returns a user token. The method will ensure to avoid unnecessary API calls by caching valid user tokens.
|
|
1957
|
-
*/
|
|
1958
|
-
const getUserToken = (userAuthConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1959
|
-
if ((currentUserToken === null || currentUserToken === void 0 ? void 0 : currentUserToken.expiresAt) === undefined ||
|
|
1960
|
-
currentUserToken.expiresAt <= new Date(Date.now())) {
|
|
1961
|
-
currentUserToken = null;
|
|
1962
|
-
}
|
|
1963
|
-
if (currentUserToken !== null) {
|
|
1964
|
-
// A valid user token is already available
|
|
1965
|
-
return Promise.resolve(currentUserToken);
|
|
1966
|
-
}
|
|
1967
|
-
currentUserToken = yield fetchUserToken(userAuthConfig);
|
|
1968
|
-
return currentUserToken;
|
|
1969
|
-
});
|
|
1970
1952
|
const logoutUser = (userAuthConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1971
1953
|
const logoutResponse = yield invokeUserAuthMethod('sign-out', userAuthConfig);
|
|
1972
1954
|
return logoutResponse.code === dist.SignOutResponseCode.SUCCESS;
|
|
@@ -2070,18 +2052,18 @@ var UsersOrderBy$1;
|
|
|
2070
2052
|
UsersOrderBy["UPDATED_USER_ASC"] = "UPDATED_USER_ASC";
|
|
2071
2053
|
UsersOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
|
|
2072
2054
|
})(UsersOrderBy$1 || (UsersOrderBy$1 = {}));
|
|
2073
|
-
const SetActiveProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "SetActiveProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "UUID" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "setActiveProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "profileId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "
|
|
2074
|
-
const GetUserProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetUserProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "UUID" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "
|
|
2075
|
-
const GetUserProfilesDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetUserProfiles" }, "variableDefinitions": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfiles" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "nodes" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "
|
|
2076
|
-
const CreateUserProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateUserProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "CreateUserProfileInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "createUserProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfile" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "
|
|
2077
|
-
const UpdateUserProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdateUserProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "UpdateUserProfileInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "updateUserProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfile" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "
|
|
2078
|
-
const DeleteUserProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "DeleteUserProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "DeleteUserProfileInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "deleteUserProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfile" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "
|
|
2055
|
+
const SetActiveProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "SetActiveProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "UUID" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "setActiveProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "profileId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "profilePictureUrl" }, "arguments": [], "directives": [] }] } }] } }] };
|
|
2056
|
+
const GetUserProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetUserProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "UUID" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "profilePictureUrl" }, "arguments": [], "directives": [] }] } }] } }] };
|
|
2057
|
+
const GetUserProfilesDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetUserProfiles" }, "variableDefinitions": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfiles" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "nodes" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "profilePictureUrl" }, "arguments": [], "directives": [] }] } }] } }] } }] };
|
|
2058
|
+
const CreateUserProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CreateUserProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "CreateUserProfileInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "createUserProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfile" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "profilePictureUrl" }, "arguments": [], "directives": [] }] } }] } }] } }] };
|
|
2059
|
+
const UpdateUserProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "UpdateUserProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "UpdateUserProfileInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "updateUserProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfile" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "profilePictureUrl" }, "arguments": [], "directives": [] }] } }] } }] } }] };
|
|
2060
|
+
const DeleteUserProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "DeleteUserProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "DeleteUserProfileInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "deleteUserProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfile" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "profilePictureUrl" }, "arguments": [], "directives": [] }] } }] } }] } }] };
|
|
2079
2061
|
|
|
2080
2062
|
const setActiveProfile = (userServiceBaseUrl, accessToken, profileId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2081
2063
|
const variables = {
|
|
2082
2064
|
profileId,
|
|
2083
2065
|
};
|
|
2084
|
-
const activeUserProfile =
|
|
2066
|
+
const activeUserProfile = yield (yield fetch(`${userServiceBaseUrl}/graphql`, {
|
|
2085
2067
|
method: 'POST',
|
|
2086
2068
|
cache: 'no-cache',
|
|
2087
2069
|
redirect: 'follow',
|
|
@@ -2091,14 +2073,24 @@ const setActiveProfile = (userServiceBaseUrl, accessToken, profileId) => __await
|
|
|
2091
2073
|
'content-type': 'application/json',
|
|
2092
2074
|
},
|
|
2093
2075
|
body: stringifyGqlQuery(SetActiveProfileDocument, variables),
|
|
2094
|
-
})).json()
|
|
2095
|
-
|
|
2076
|
+
})).json();
|
|
2077
|
+
if (activeUserProfile.errors === undefined) {
|
|
2078
|
+
return {
|
|
2079
|
+
code: 'SUCCESS',
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
else {
|
|
2083
|
+
return {
|
|
2084
|
+
code: 'ERROR',
|
|
2085
|
+
message: activeUserProfile.errors[0].message,
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2096
2088
|
});
|
|
2097
2089
|
const getUserProfile = (userServiceBaseUrl, accessToken, profileId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2098
2090
|
const variables = {
|
|
2099
2091
|
profileId,
|
|
2100
2092
|
};
|
|
2101
|
-
const
|
|
2093
|
+
const userProfileResponse = yield (yield fetch(`${userServiceBaseUrl}/graphql`, {
|
|
2102
2094
|
method: 'POST',
|
|
2103
2095
|
cache: 'no-cache',
|
|
2104
2096
|
redirect: 'follow',
|
|
@@ -2108,11 +2100,22 @@ const getUserProfile = (userServiceBaseUrl, accessToken, profileId) => __awaiter
|
|
|
2108
2100
|
'content-type': 'application/json',
|
|
2109
2101
|
},
|
|
2110
2102
|
body: stringifyGqlQuery(GetUserProfileDocument, variables),
|
|
2111
|
-
})).json()
|
|
2112
|
-
|
|
2103
|
+
})).json();
|
|
2104
|
+
if (userProfileResponse.errors === undefined) {
|
|
2105
|
+
return {
|
|
2106
|
+
code: 'SUCCESS',
|
|
2107
|
+
userProfile: userProfileResponse.data.userProfile,
|
|
2108
|
+
};
|
|
2109
|
+
}
|
|
2110
|
+
else {
|
|
2111
|
+
return {
|
|
2112
|
+
code: 'ERROR',
|
|
2113
|
+
message: userProfileResponse.errors[0].message,
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
2113
2116
|
});
|
|
2114
2117
|
const getUserProfiles = (userServiceBaseUrl, accessToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2115
|
-
const
|
|
2118
|
+
const userProfilesResponse = yield (yield fetch(`${userServiceBaseUrl}/graphql`, {
|
|
2116
2119
|
method: 'POST',
|
|
2117
2120
|
cache: 'no-cache',
|
|
2118
2121
|
redirect: 'follow',
|
|
@@ -2122,18 +2125,30 @@ const getUserProfiles = (userServiceBaseUrl, accessToken) => __awaiter(void 0, v
|
|
|
2122
2125
|
'content-type': 'application/json',
|
|
2123
2126
|
},
|
|
2124
2127
|
body: stringifyGqlQuery(GetUserProfilesDocument),
|
|
2125
|
-
})).json()
|
|
2126
|
-
|
|
2128
|
+
})).json();
|
|
2129
|
+
if (userProfilesResponse.errors === undefined) {
|
|
2130
|
+
return {
|
|
2131
|
+
code: 'SUCCESS',
|
|
2132
|
+
userProfiles: userProfilesResponse.data.userProfiles.nodes,
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
else {
|
|
2136
|
+
return {
|
|
2137
|
+
code: 'ERROR',
|
|
2138
|
+
message: userProfilesResponse.errors[0].message,
|
|
2139
|
+
};
|
|
2140
|
+
}
|
|
2127
2141
|
});
|
|
2128
|
-
const createUserProfile = (userServiceBaseUrl, accessToken, displayName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2142
|
+
const createUserProfile = (userServiceBaseUrl, accessToken, displayName, profilePictureUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2129
2143
|
const variables = {
|
|
2130
2144
|
input: {
|
|
2131
2145
|
userProfile: {
|
|
2132
2146
|
displayName: displayName,
|
|
2147
|
+
profilePictureUrl: profilePictureUrl === '' ? null : profilePictureUrl,
|
|
2133
2148
|
},
|
|
2134
2149
|
},
|
|
2135
2150
|
};
|
|
2136
|
-
const
|
|
2151
|
+
const createUserProfileResponse = yield (yield fetch(`${userServiceBaseUrl}/graphql`, {
|
|
2137
2152
|
method: 'POST',
|
|
2138
2153
|
cache: 'no-cache',
|
|
2139
2154
|
redirect: 'follow',
|
|
@@ -2143,8 +2158,19 @@ const createUserProfile = (userServiceBaseUrl, accessToken, displayName) => __aw
|
|
|
2143
2158
|
'content-type': 'application/json',
|
|
2144
2159
|
},
|
|
2145
2160
|
body: stringifyGqlQuery(CreateUserProfileDocument, variables),
|
|
2146
|
-
})).json()
|
|
2147
|
-
|
|
2161
|
+
})).json();
|
|
2162
|
+
if (createUserProfileResponse.errors === undefined) {
|
|
2163
|
+
return {
|
|
2164
|
+
code: 'SUCCESS',
|
|
2165
|
+
createdUserProfile: createUserProfileResponse.data.createUserProfile.userProfile,
|
|
2166
|
+
};
|
|
2167
|
+
}
|
|
2168
|
+
else {
|
|
2169
|
+
return {
|
|
2170
|
+
code: 'ERROR',
|
|
2171
|
+
message: createUserProfileResponse.errors[0].message,
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2148
2174
|
});
|
|
2149
2175
|
/**
|
|
2150
2176
|
* Updates a user profile
|
|
@@ -2157,12 +2183,13 @@ const updateUserProfile = (userServiceBaseUrl, accessToken, userProfileToUpdate)
|
|
|
2157
2183
|
id: userProfileToUpdate.id,
|
|
2158
2184
|
patch: {
|
|
2159
2185
|
displayName: userProfileToUpdate.displayName,
|
|
2160
|
-
profilePictureUrl: userProfileToUpdate.profilePictureUrl
|
|
2161
|
-
|
|
2186
|
+
profilePictureUrl: userProfileToUpdate.profilePictureUrl === ''
|
|
2187
|
+
? null
|
|
2188
|
+
: userProfileToUpdate.profilePictureUrl,
|
|
2162
2189
|
},
|
|
2163
2190
|
},
|
|
2164
2191
|
};
|
|
2165
|
-
const
|
|
2192
|
+
const updateUserProfileResponse = yield (yield fetch(`${userServiceBaseUrl}/graphql`, {
|
|
2166
2193
|
method: 'POST',
|
|
2167
2194
|
cache: 'no-cache',
|
|
2168
2195
|
redirect: 'follow',
|
|
@@ -2172,8 +2199,19 @@ const updateUserProfile = (userServiceBaseUrl, accessToken, userProfileToUpdate)
|
|
|
2172
2199
|
'content-type': 'application/json',
|
|
2173
2200
|
},
|
|
2174
2201
|
body: stringifyGqlQuery(UpdateUserProfileDocument, variables),
|
|
2175
|
-
})).json()
|
|
2176
|
-
|
|
2202
|
+
})).json();
|
|
2203
|
+
if (updateUserProfileResponse.errors === undefined) {
|
|
2204
|
+
return {
|
|
2205
|
+
code: 'SUCCESS',
|
|
2206
|
+
updatedUserProfile: updateUserProfileResponse.data.updateUserProfile.userProfile,
|
|
2207
|
+
};
|
|
2208
|
+
}
|
|
2209
|
+
else {
|
|
2210
|
+
return {
|
|
2211
|
+
code: 'ERROR',
|
|
2212
|
+
message: updateUserProfileResponse.errors[0].message,
|
|
2213
|
+
};
|
|
2214
|
+
}
|
|
2177
2215
|
});
|
|
2178
2216
|
const deleteUserProfile = (userServiceBaseUrl, accessToken, userProfileId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2179
2217
|
const variables = {
|
|
@@ -2181,7 +2219,7 @@ const deleteUserProfile = (userServiceBaseUrl, accessToken, userProfileId) => __
|
|
|
2181
2219
|
id: userProfileId,
|
|
2182
2220
|
},
|
|
2183
2221
|
};
|
|
2184
|
-
const
|
|
2222
|
+
const deleteUserProfileResponse = yield (yield fetch(`${userServiceBaseUrl}/graphql`, {
|
|
2185
2223
|
method: 'POST',
|
|
2186
2224
|
cache: 'no-cache',
|
|
2187
2225
|
redirect: 'follow',
|
|
@@ -2191,8 +2229,19 @@ const deleteUserProfile = (userServiceBaseUrl, accessToken, userProfileId) => __
|
|
|
2191
2229
|
'content-type': 'application/json',
|
|
2192
2230
|
},
|
|
2193
2231
|
body: stringifyGqlQuery(DeleteUserProfileDocument, variables),
|
|
2194
|
-
})).json()
|
|
2195
|
-
|
|
2232
|
+
})).json();
|
|
2233
|
+
if (deleteUserProfileResponse.errors === undefined) {
|
|
2234
|
+
return {
|
|
2235
|
+
code: 'SUCCESS',
|
|
2236
|
+
deletedUserProfile: deleteUserProfileResponse.data.deleteUserProfile.userProfile,
|
|
2237
|
+
};
|
|
2238
|
+
}
|
|
2239
|
+
else {
|
|
2240
|
+
return {
|
|
2241
|
+
code: 'ERROR',
|
|
2242
|
+
message: deleteUserProfileResponse.errors[0].message,
|
|
2243
|
+
};
|
|
2244
|
+
}
|
|
2196
2245
|
});
|
|
2197
2246
|
|
|
2198
2247
|
/**
|
|
@@ -2225,11 +2274,11 @@ class UserServiceClient {
|
|
|
2225
2274
|
this.fetchToken = () => __awaiter(this, void 0, void 0, function* () {
|
|
2226
2275
|
try {
|
|
2227
2276
|
const userToken = yield fetchUserToken(this.userAuthConfig);
|
|
2228
|
-
const
|
|
2277
|
+
const userProfileResponse = yield getUserProfile(this.userServiceConfig.userServiceBaseUrl, userToken.accessToken, userToken.profileId);
|
|
2229
2278
|
return {
|
|
2230
2279
|
code: 'SUCCESS',
|
|
2231
2280
|
userToken,
|
|
2232
|
-
userProfile,
|
|
2281
|
+
userProfile: userProfileResponse.userProfile,
|
|
2233
2282
|
nextTokenRenewalAt: new Date(Date.now() +
|
|
2234
2283
|
(userToken.expiresInSeconds -
|
|
2235
2284
|
inAdvanceTokenRenewalDurationInSeconds) *
|
|
@@ -2531,49 +2580,79 @@ class UserServiceClient {
|
|
|
2531
2580
|
/**
|
|
2532
2581
|
* Sets a given Profile ID as the active profile
|
|
2533
2582
|
*/
|
|
2534
|
-
this.setActiveProfile = (profileId) => __awaiter(this, void 0, void 0, function* () {
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2583
|
+
this.setActiveProfile = (endUserAccessToken, profileId) => __awaiter(this, void 0, void 0, function* () {
|
|
2584
|
+
try {
|
|
2585
|
+
const result = yield setActiveProfile(this.userServiceConfig.userServiceBaseUrl, endUserAccessToken, profileId);
|
|
2586
|
+
// current token is invalid now since the active profile has changed
|
|
2587
|
+
// we clear the current token response here so that the next call will retrieve a new token
|
|
2588
|
+
this.tokenResponse = null;
|
|
2589
|
+
return result;
|
|
2590
|
+
}
|
|
2591
|
+
catch (error) {
|
|
2592
|
+
assertError(error);
|
|
2593
|
+
return { code: 'ERROR', message: error.message };
|
|
2594
|
+
}
|
|
2541
2595
|
});
|
|
2542
2596
|
/**
|
|
2543
2597
|
* Returns a user profile
|
|
2544
2598
|
*/
|
|
2545
|
-
this.getUserProfile = (profileId) => __awaiter(this, void 0, void 0, function* () {
|
|
2546
|
-
|
|
2547
|
-
|
|
2599
|
+
this.getUserProfile = (endUserAccessToken, profileId) => __awaiter(this, void 0, void 0, function* () {
|
|
2600
|
+
try {
|
|
2601
|
+
return getUserProfile(this.userServiceConfig.userServiceBaseUrl, endUserAccessToken, profileId);
|
|
2602
|
+
}
|
|
2603
|
+
catch (error) {
|
|
2604
|
+
assertError(error);
|
|
2605
|
+
return { code: 'ERROR', message: error.message };
|
|
2606
|
+
}
|
|
2548
2607
|
});
|
|
2549
2608
|
/**
|
|
2550
2609
|
* Returns an array of all user profiles
|
|
2551
2610
|
*/
|
|
2552
|
-
this.getUserProfiles = () => __awaiter(this, void 0, void 0, function* () {
|
|
2553
|
-
|
|
2554
|
-
|
|
2611
|
+
this.getUserProfiles = (endUserAccessToken) => __awaiter(this, void 0, void 0, function* () {
|
|
2612
|
+
try {
|
|
2613
|
+
return getUserProfiles(this.userServiceConfig.userServiceBaseUrl, endUserAccessToken);
|
|
2614
|
+
}
|
|
2615
|
+
catch (error) {
|
|
2616
|
+
assertError(error);
|
|
2617
|
+
return { code: 'ERROR', message: error.message };
|
|
2618
|
+
}
|
|
2555
2619
|
});
|
|
2556
2620
|
/**
|
|
2557
2621
|
* Creates a new user profile
|
|
2558
2622
|
*/
|
|
2559
|
-
this.createUserProfile = (displayName) => __awaiter(this, void 0, void 0, function* () {
|
|
2560
|
-
|
|
2561
|
-
|
|
2623
|
+
this.createUserProfile = (endUserAccessToken, displayName, profilePictureUrl) => __awaiter(this, void 0, void 0, function* () {
|
|
2624
|
+
try {
|
|
2625
|
+
return createUserProfile(this.userServiceConfig.userServiceBaseUrl, endUserAccessToken, displayName, profilePictureUrl);
|
|
2626
|
+
}
|
|
2627
|
+
catch (error) {
|
|
2628
|
+
assertError(error);
|
|
2629
|
+
return { code: 'ERROR', message: error.message };
|
|
2630
|
+
}
|
|
2562
2631
|
});
|
|
2563
2632
|
/**
|
|
2564
2633
|
* Updates a user profile
|
|
2565
2634
|
* @param userProfileToUpdate User Profile object with required updates. This should be based on the current user profile object, with the required changes done on top of it.
|
|
2566
2635
|
*/
|
|
2567
|
-
this.updateUserProfile = (userProfileToUpdate) => __awaiter(this, void 0, void 0, function* () {
|
|
2568
|
-
|
|
2569
|
-
|
|
2636
|
+
this.updateUserProfile = (endUserAccessToken, userProfileToUpdate) => __awaiter(this, void 0, void 0, function* () {
|
|
2637
|
+
try {
|
|
2638
|
+
return updateUserProfile(this.userServiceConfig.userServiceBaseUrl, endUserAccessToken, userProfileToUpdate);
|
|
2639
|
+
}
|
|
2640
|
+
catch (error) {
|
|
2641
|
+
assertError(error);
|
|
2642
|
+
return { code: 'ERROR', message: error.message };
|
|
2643
|
+
}
|
|
2570
2644
|
});
|
|
2571
2645
|
/**
|
|
2572
2646
|
* Deletes a user profile
|
|
2573
2647
|
*/
|
|
2574
|
-
this.deleteUserProfile = (userProfileId) => __awaiter(this, void 0, void 0, function* () {
|
|
2575
|
-
|
|
2576
|
-
|
|
2648
|
+
this.deleteUserProfile = (endUserAccessToken, userProfileId) => __awaiter(this, void 0, void 0, function* () {
|
|
2649
|
+
try {
|
|
2650
|
+
return deleteUserProfile(this.userServiceConfig.userServiceBaseUrl, endUserAccessToken, userProfileId);
|
|
2651
|
+
}
|
|
2652
|
+
catch (error) {
|
|
2653
|
+
assertError(error);
|
|
2654
|
+
return { code: 'ERROR', message: error.message };
|
|
2655
|
+
}
|
|
2577
2656
|
});
|
|
2578
2657
|
/**
|
|
2579
2658
|
* Authenticate a consumer application and receive an Application Token
|