Skip to content
Snippets Groups Projects
Commit c4557e2c authored by Josh Brooks's avatar Josh Brooks
Browse files

Merge branch 'XX-4600/DmURL' into 'release'

Add DM URL sharing to WASM

See merge request !96
parents 90dda613 fdc74a61
No related branches found
No related tags found
2 merge requests!96Add DM URL sharing to WASM,!67fix for latest client release
......@@ -7,7 +7,7 @@ require (
github.com/hack-pad/go-indexeddb v0.2.0
github.com/pkg/errors v0.9.1
github.com/spf13/jwalterweatherman v1.1.0
gitlab.com/elixxir/client/v4 v4.6.2-0.20230404214725-85793f3ddac0
gitlab.com/elixxir/client/v4 v4.6.2-0.20230410180037-176b80ba79e7
gitlab.com/elixxir/crypto v0.0.7-0.20230322181929-8cb5fa100824
gitlab.com/elixxir/primitives v0.0.3-0.20230214180039-9a25e2d3969c
gitlab.com/xx_network/crypto v0.0.5-0.20230214003943-8a09396e95dd
......@@ -24,26 +24,40 @@ require (
github.com/cloudflare/circl v1.2.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/elliotchance/orderedmap v1.4.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gobwas/ws v1.1.0 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20221003100820-41fad3beba17 // indirect
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/pkg/profile v1.6.0 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/sethvargo/go-diceware v0.3.0 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect
github.com/ttacon/libphonenumber v1.2.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
......@@ -64,6 +78,9 @@ require (
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect
google.golang.org/grpc v1.49.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/sqlite v1.4.4 // indirect
gorm.io/gorm v1.24.3 // indirect
nhooyr.io/websocket v1.8.7 // indirect
......
This diff is collapsed.
......@@ -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