Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,23 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.18.0] - 2022-08-18

- Adds `LOG_LEVEL` enum, and changes `initFileLogging` interface function to accept a log level.

## [2.17.0] - 2022-08-10

- Adds `getUserIdMappingForSuperTokensIds` to the UserIdMapping Interface
- Adds `isUserIdBeingUsedInNonAuthRecipe` and `addInfoToNonAuthRecipesBasedOnUserId` to the Storage Interface
- Adds `NonAuthRecipeStorage` Interface
- All non-auth recipes now extend the `NonAuthRecipeStorage` Interface

## [2.16.0] - 2022-07-25

- UserId Mapping interface

## [2.16.0] - 2022-07-25

## [2.15.0] - 2022-06-07

- Changes name of `getAllSessionHandlesForUser` to `getAllNonExpiredSessionHandlesForUser`.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java-library'
}

version = "2.16.0"
version = "2.18.0"

repositories {
mavenCentral()
Expand Down
Binary file not shown.
22 changes: 22 additions & 0 deletions src/main/java/io/supertokens/pluginInterface/LOG_LEVEL.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2020, VRAI Labs and/or its affiliates. All rights reserved.
*
* This software is licensed under the Apache License, Version 2.0 (the
* "License") as published by the Apache Software Foundation.
*
* You may not use this file except in compliance with the License. You may
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/

package io.supertokens.pluginInterface;

public enum LOG_LEVEL {
NONE, DEBUG, INFO, WARN, ERROR
}
11 changes: 10 additions & 1 deletion src/main/java/io/supertokens/pluginInterface/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

import io.supertokens.pluginInterface.exceptions.StorageQueryException;

import java.util.Set;

public interface Storage {

// if silent is true, do not log anything out on the console
void constructor(String processId, boolean silent);

void loadConfig(String configFilePath);
void loadConfig(String configFilePath, Set<LOG_LEVEL> logLevels);

void initFileLogging(String infoLogPath, String errorLogPath);

Expand All @@ -49,4 +51,11 @@ public interface Storage {

boolean canBeUsed(String configFilePath);

// this function will be used in the createUserIdMapping and deleteUserIdMapping functions to check if the userId is
// being used in NonAuth recipes.
boolean isUserIdBeingUsedInNonAuthRecipe(String className, String userId) throws StorageQueryException;

// to be used for testing purposes only. This function will add dummy data to non-auth tables.
void addInfoToNonAuthRecipesBasedOnUserId(String className, String userId) throws StorageQueryException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.emailverification.exception.DuplicateEmailVerificationTokenException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage;

public interface EmailVerificationStorage extends Storage {
public interface EmailVerificationStorage extends NonAuthRecipeStorage {

void addEmailVerificationToken(EmailVerificationTokenInfo emailVerificationInfo)
throws StorageQueryException, DuplicateEmailVerificationTokenException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package io.supertokens.pluginInterface.jwt;

import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage;

public interface JWTRecipeStorage extends Storage {
public interface JWTRecipeStorage extends NonAuthRecipeStorage {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2022, VRAI Labs and/or its affiliates. All rights reserved.
*
* This software is licensed under the Apache License, Version 2.0 (the
* "License") as published by the Apache Software Foundation.
*
* You may not use this file except in compliance with the License. You may
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

package io.supertokens.pluginInterface.nonAuthRecipe;

import io.supertokens.pluginInterface.Storage;

// All Non-Auth Recipes will extend this interface.
// We will use this interface in testing to check If the createUserIdMapping and deleteUserIdMapping functions have checks for all nonAuthRecipes
public interface NonAuthRecipeStorage extends Storage {
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import com.google.gson.JsonObject;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage;

import javax.annotation.Nullable;

public interface SessionStorage extends Storage {
public interface SessionStorage extends NonAuthRecipeStorage {
void createNewSession(String sessionHandle, String userId, String refreshTokenHash2, JsonObject userDataInDatabase,
long expiry, JsonObject userDataInJWT, long createdAtTime) throws StorageQueryException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import io.supertokens.pluginInterface.useridmapping.exception.UserIdMappingAlreadyExistsException;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashMap;

public interface UserIdMappingStorage extends Storage {

Expand All @@ -37,4 +39,9 @@ void createUserIdMapping(String superTokensUserId, String externalUserId, @Nulla
boolean updateOrDeleteExternalUserIdInfo(String userId, boolean isSuperTokensUserId,
@Nullable String externalUserIdInfo) throws StorageQueryException;

// This function will be used to retrieve the userId mapping for a list of userIds. The key of the HashMap will be
// superTokensUserId and the value will be the externalUserId. If a mapping does not exist for an input userId,
// it will not be in a part of the returned HashMap
HashMap<String, String> getUserIdMappingForSuperTokensIds(ArrayList<String> userIds) throws StorageQueryException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import com.google.gson.JsonObject;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage;

public interface UserMetadataStorage extends Storage {
public interface UserMetadataStorage extends NonAuthRecipeStorage {
JsonObject getUserMetadata(String userId) throws StorageQueryException;

int deleteUserMetadata(String userId) throws StorageQueryException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import com.google.gson.JsonObject;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage;
import io.supertokens.pluginInterface.userroles.exception.DuplicateUserRoleMappingException;
import io.supertokens.pluginInterface.userroles.exception.UnknownRoleException;

public interface UserRolesStorage extends Storage {
public interface UserRolesStorage extends NonAuthRecipeStorage {

// associate a userId with a role that exists
void addRoleToUser(String userId, String role)
Expand Down