Skip to content
Snippets Groups Projects
Commit 90fd89be authored by Jake Taylor's avatar Jake Taylor :lips:
Browse files

Merge branch 'release' into project/fileUpload

# Conflicts:
#	go.mod
#	go.sum
parents fc19e7d2 c4557e2c
No related branches found
No related tags found
2 merge requests!71Project/file upload,!67fix for latest client release
......@@ -77,7 +77,7 @@ func (m *manager) newWASMEventModelCB(data []byte) ([]byte, error) {
return []byte(err.Error()), nil
}
return nil, nil
return []byte{}, nil
}
// messageReceivedCallback sends calls to the channels.MessageReceivedCallback
......
......@@ -74,7 +74,7 @@ func (m *manager) newWASMEventModelCB(data []byte) ([]byte, error) {
return []byte(err.Error()), nil
}
return nil, nil
return []byte{}, nil
}
// messageReceivedCallback sends calls to the MessageReceivedCallback in the
......
......@@ -121,7 +121,7 @@ func NewWASMEventModel(path, wasmJsPath string, encryption cryptoChannel.Cipher,
select {
case data := <-dataChan:
if data != nil {
if len(data) > 0 {
return nil, errors.New(string(data))
}
case <-time.After(worker.ResponseTimeout):
......
......@@ -89,7 +89,7 @@ func NewWASMEventModel(path, wasmJsPath string, encryption cryptoChannel.Cipher,
select {
case data := <-dataChan:
if data != nil {
if len(data) > 0 {
return nil, errors.New(string(data))
}
case <-time.After(worker.ResponseTimeout):
......
......@@ -531,6 +531,77 @@ func (dmc *DMClient) GetDatabaseName(js.Value, []js.Value) any {
"_speakeasy_dm"
}
////////////////////////////////////////////////////////////////////////////////
// DM Share URL //
////////////////////////////////////////////////////////////////////////////////
// DMShareURL is returned from [DMClient.GetShareURL]. It includes the
// user's share URL.
//
// JSON example for a user:
//
// {
// "url": "https://internet.speakeasy.tech/?l=32&m=5&p=EfDzQDa4fQ5BoqNIMbECFDY9ckRr_fadd8F1jE49qJc%3D&t=4231817746&v=1",
// "password": "hunter2",
// }
type DMShareURL struct {
URL string `json:"url"`
Password string `json:"password"`
}
// DMUser is returned from [DecodeDMShareURL]. It includes the token
// and public key of the user who created the URL.
//
// JSON example for a user:
//
// {
// "token": 4231817746,
// "publicKey": "EfDzQDa4fQ5BoqNIMbECFDY9ckRr/fadd8F1jE49qJc="
// }
type DMUser struct {
Token int32 `json:"token"`
PublicKey []byte `json:"publicKey"`
}
// GetShareURL generates a URL that can be used to share a URL to initiate a
// direct messages with this user.
//
// Parameters:
// - args[0] - The URL to append the DM info to (string).
//
// Returns:
// - JSON of [DMShareURL] (Uint8Array).
func (dmc *DMClient) GetShareURL(_ js.Value, args []js.Value) any {
host := args[0].String()
urlReport, err := dmc.api.GetShareURL(host)
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
}
return utils.CopyBytesToJS(urlReport)
}
// DecodeDMShareURL decodes the user's URL into a [DMUser].
//
// Parameters:
// - args[0] - The user's share URL. Should be received from another user or
// generated via [DMClient.GetShareURL] (string).
//
// Returns:
// - JSON of [DMUser] (Uint8Array).
func DecodeDMShareURL(_ js.Value, args []js.Value) any {
url := args[0].String()
report, err := bindings.DecodeDMShareURL(url)
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
}
return utils.CopyBytesToJS(report)
}
////////////////////////////////////////////////////////////////////////////////
// Channel Receiving Logic and Callback Registration //
////////////////////////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment