|
@@ -1,18 +1,12 @@
|
|
package service
|
|
package service
|
|
|
|
|
|
import (
|
|
import (
|
|
- "errors"
|
|
|
|
"fmt"
|
|
"fmt"
|
|
- "io"
|
|
|
|
- "mime/multipart"
|
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
- "github.com/gin-gonic/gin"
|
|
|
|
"github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/core/plugin_manager"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/core/plugin_packager/decoder"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/core/plugin_packager/decoder"
|
|
- "github.com/langgenius/dify-plugin-daemon/internal/core/plugin_packager/verifier"
|
|
|
|
"github.com/langgenius/dify-plugin-daemon/internal/db"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/db"
|
|
- "github.com/langgenius/dify-plugin-daemon/internal/types/app"
|
|
|
|
"github.com/langgenius/dify-plugin-daemon/internal/types/entities"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/types/entities"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/types/models"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/types/models"
|
|
@@ -22,40 +16,6 @@ import (
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm"
|
|
)
|
|
)
|
|
|
|
|
|
-func UploadPluginFromPkg(
|
|
|
|
- config *app.Config,
|
|
|
|
- c *gin.Context,
|
|
|
|
- tenant_id string,
|
|
|
|
- dify_pkg_file multipart.File,
|
|
|
|
- verify_signature bool,
|
|
|
|
-) *entities.Response {
|
|
|
|
- plugin_file, err := io.ReadAll(dify_pkg_file)
|
|
|
|
- if err != nil {
|
|
|
|
- return entities.NewErrorResponse(-500, err.Error())
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- decoder, err := decoder.NewZipPluginDecoder(plugin_file)
|
|
|
|
- if err != nil {
|
|
|
|
- return entities.NewErrorResponse(-500, err.Error())
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if config.ForceVerifyingSignature || verify_signature {
|
|
|
|
- err := verifier.VerifyPlugin(decoder)
|
|
|
|
- if err != nil {
|
|
|
|
- return entities.NewErrorResponse(-500, errors.Join(err, errors.New(
|
|
|
|
- "plugin verification has been enabled, and the plugin you want to install has a bad signature",
|
|
|
|
- )).Error())
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- manifest, err := decoder.Manifest()
|
|
|
|
- if err != nil {
|
|
|
|
- return entities.NewErrorResponse(-500, err.Error())
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return entities.NewSuccessResponse(manifest.Identity())
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func InstallPluginFromIdentifiers(
|
|
func InstallPluginFromIdentifiers(
|
|
tenant_id string,
|
|
tenant_id string,
|
|
plugin_unique_identifiers []plugin_entities.PluginUniqueIdentifier,
|
|
plugin_unique_identifiers []plugin_entities.PluginUniqueIdentifier,
|
|
@@ -284,13 +244,6 @@ func FetchPluginInstallationTask(
|
|
return entities.NewSuccessResponse(task)
|
|
return entities.NewSuccessResponse(task)
|
|
}
|
|
}
|
|
|
|
|
|
-func FetchPluginManifest(
|
|
|
|
- tenant_id string,
|
|
|
|
- plugin_unique_identifier plugin_entities.PluginUniqueIdentifier,
|
|
|
|
-) *entities.Response {
|
|
|
|
- return nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func FetchPluginFromIdentifier(
|
|
func FetchPluginFromIdentifier(
|
|
plugin_unique_identifier plugin_entities.PluginUniqueIdentifier,
|
|
plugin_unique_identifier plugin_entities.PluginUniqueIdentifier,
|
|
) *entities.Response {
|
|
) *entities.Response {
|