Skip to content
Open
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
10 changes: 9 additions & 1 deletion client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewClient(ctx context.Context, opts ...ClientOption) (*Client, error) {
var core *internal.CoreWrapper
var err error
if client.config.AccountName != nil {
core, err = internal.GetSharedLibCore(*client.config.AccountName)
core, err = internal.GetSharedLibCore(*client.config.AccountName, client.config.SharedLibraryPath)
} else {
core, err = internal.GetExtismCore()
}
Expand Down Expand Up @@ -94,6 +94,14 @@ func WithDesktopAppIntegration(accountName string) ClientOption {
}
}

// WithSharedLibraryPath specifies a custom path to load the shared library (dll/dylib/so) file from
func WithSharedLibraryPath(path string) ClientOption {
return func(c *Client) error {
c.config.SharedLibraryPath = path
return nil
}
}

func clientInvoke(ctx context.Context, innerClient *internal.InnerClient, invocation string, params map[string]interface{}) (*string, error) {
invocationResponse, err := innerClient.Core.Invoke(ctx, internal.InvokeConfig{
Invocation: internal.Invocation{
Expand Down
1 change: 1 addition & 0 deletions internal/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type ClientConfig struct {
SAToken string `json:"serviceAccountToken"`
Language string `json:"programmingLanguage"`
SDKVersion string `json:"sdkVersion"`
SharedLibraryPath string `json:"sharedLibraryPath"`
IntegrationName string `json:"integrationName"`
IntegrationVersion string `json:"integrationVersion"`
RequestLibraryName string `json:"requestLibraryName"`
Expand Down
9 changes: 6 additions & 3 deletions internal/shared_lib_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (r Response) Error() string { return string(r.Payload) }

// find1PasswordLibPath returns the path to the 1Password shared library
// (libop_sdk_ipc_client.dylib/.so/.dll) depending on OS.
func find1PasswordLibPath() (string, error) {
func find1PasswordLibPath(customLocation string) (string, error) {
var locations []string

home, err := os.UserHomeDir()
Expand Down Expand Up @@ -59,6 +59,9 @@ func find1PasswordLibPath() (string, error) {
default:
return "", fmt.Errorf("unsupported OS: %s", runtime.GOOS)
}
if customLocation != "" {
locations = append([]string{customLocation}, locations...)
}
for _, libPath := range locations {
if _, err := os.Stat(libPath); err == nil {
return libPath, nil
Expand All @@ -68,9 +71,9 @@ func find1PasswordLibPath() (string, error) {
return "", fmt.Errorf("1Password desktop application not found")
}

func GetSharedLibCore(accountName string) (*CoreWrapper, error) {
func GetSharedLibCore(accountName string, libraryPath string) (*CoreWrapper, error) {
if coreLib == nil {
libPath, err := find1PasswordLibPath()
libPath, err := find1PasswordLibPath(libraryPath)
if err != nil {
return nil, err
}
Expand Down