diff --git a/go.mod b/go.mod index f505c8601e9..3459f8932bb 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/grafana/xk6-dashboard v0.7.4 github.com/grafana/xk6-output-prometheus-remote v0.3.1 github.com/grafana/xk6-redis v0.2.0 - github.com/grafana/xk6-webcrypto v0.3.0 + github.com/grafana/xk6-webcrypto v0.4.0 github.com/grafana/xk6-websockets v0.5.1 github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc diff --git a/go.sum b/go.sum index 451ae66f479..d14fd09efb9 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,8 @@ github.com/grafana/xk6-output-prometheus-remote v0.3.1 h1:X23rQzlJD8dXWB31DkxR4u github.com/grafana/xk6-output-prometheus-remote v0.3.1/go.mod h1:0JLAm4ONsNUlNoxJXAwOCfA6GtDwTPs557OplAvE+3o= github.com/grafana/xk6-redis v0.2.0 h1:iXmAKVlAxafZ/h8ptuXTFhGu63IFsyDI8QjUgWm66BU= github.com/grafana/xk6-redis v0.2.0/go.mod h1:B3PA9PAPJa2/WUfNJCdQwZrbb6D4e6UHIk8dssQbj7w= -github.com/grafana/xk6-webcrypto v0.3.0 h1:piwiTrLTQDbuzC4CK0dVjbzQqNhIoGjWXrflf++W8aE= -github.com/grafana/xk6-webcrypto v0.3.0/go.mod h1:Jk+UKbo+w/RCQH0hi+Hoy7Uj2HWd+dwEBjn1EDpwY0w= +github.com/grafana/xk6-webcrypto v0.4.0 h1:CXRGkvVg8snYEyGCq3d5XGzDPxTPJ1m5CS68jPdtZZk= +github.com/grafana/xk6-webcrypto v0.4.0/go.mod h1:+THllImZ8OWlsFc8llWqvzzjottlGdXq/7rIQ16zmFs= github.com/grafana/xk6-websockets v0.5.1 h1:wymI6UWpwDorv3mEInytrQjC9cmXYxQFygBOCMY1q6k= github.com/grafana/xk6-websockets v0.5.1/go.mod h1:yPadv8R00MPCnV+GGSlYV/vwVgxKRCiiJoIfWsNGoQg= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/aes.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/aes.go index 82d90ffe8f5..ca6b41a71fb 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/aes.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/aes.go @@ -8,7 +8,7 @@ import ( "errors" "fmt" - "github.com/dop251/goja" + "github.com/grafana/sobek" ) // AESKeyGenParams represents the object that should be passed as @@ -35,7 +35,7 @@ func (akgp AESKeyGenParams) alg() string { // // It handles the logic involved in handling the `length` attribute, // which is not part of the normalized algorithm. -func newAESKeyGenParams(rt *goja.Runtime, normalized Algorithm, params goja.Value) (*AESKeyGenParams, error) { +func newAESKeyGenParams(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (*AESKeyGenParams, error) { // We extract the length attribute from the params object, as it's not // part of the normalized algorithm, and as accessing the runtime from the // callback below could lead to a race condition. diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/algorithm.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/algorithm.go index 01c4f92c99f..b7bb448028f 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/algorithm.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/algorithm.go @@ -4,7 +4,7 @@ import ( "reflect" "strings" - "github.com/dop251/goja" + "github.com/grafana/sobek" ) // Algorithm represents @@ -16,7 +16,7 @@ type Algorithm struct { // As defined by the [specification] // // Note that it is defined as an alias of string, instead of a dedicated type, -// to ensure it is handled as a string by goja. +// to ensure it is handled as a string by sobek. // // [specification]: https://www.w3.org/TR/WebCryptoAPI/#algorithm-dictionary type AlgorithmIdentifier = string @@ -56,7 +56,7 @@ const ( // HashAlgorithmIdentifier represents the name of a hash algorithm. // // Note that it is defined as an alias of string, instead of a dedicated type, -// to ensure it is handled as a string under the hood by goja. +// to ensure it is handled as a string under the hood by sobek. type HashAlgorithmIdentifier = AlgorithmIdentifier const ( @@ -76,7 +76,7 @@ const ( // OperationIdentifier represents the name of an operation. // // Note that it is defined as an alias of string, instead of a dedicated type, -// to ensure it is handled as a string by goja. +// to ensure it is handled as a string by sobek. type OperationIdentifier = string const ( @@ -121,7 +121,7 @@ const ( // algorithm described in the WebCrypto [specification]. // // [specification]: https://www.w3.org/TR/WebCryptoAPI/#algorithm-normalization-normalize-an-algorithm -func normalizeAlgorithm(rt *goja.Runtime, v goja.Value, op AlgorithmIdentifier) (Algorithm, error) { +func normalizeAlgorithm(rt *sobek.Runtime, v sobek.Value, op AlgorithmIdentifier) (Algorithm, error) { var algorithm Algorithm // "if alg is an instance of a DOMString: return the result of the running the diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/crypto.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/crypto.go index 484de93c06f..8ed00918cb0 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/crypto.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/crypto.go @@ -5,8 +5,8 @@ import ( "fmt" "strconv" - "github.com/dop251/goja" "github.com/google/uuid" + "github.com/grafana/sobek" "go.k6.io/k6/js/common" "go.k6.io/k6/js/modules" ) @@ -35,7 +35,7 @@ type Crypto struct { // generator. // // [specification]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues -func (c *Crypto) GetRandomValues(typedArray goja.Value) goja.Value { +func (c *Crypto) GetRandomValues(typedArray sobek.Value) sobek.Value { acceptedTypes := []JSType{ Int8ArrayConstructor, Uint8ArrayConstructor, diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/elliptic_curve.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/elliptic_curve.go index e205e7ebd32..1cb48637103 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/elliptic_curve.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/elliptic_curve.go @@ -10,7 +10,7 @@ import ( "fmt" "math/big" - "github.com/dop251/goja" + "github.com/grafana/sobek" ) const ( @@ -39,7 +39,7 @@ type EcKeyImportParams struct { NamedCurve EllipticCurveKind `js:"namedCurve"` } -func newEcKeyImportParams(rt *goja.Runtime, normalized Algorithm, params goja.Value) (*EcKeyImportParams, error) { +func newEcKeyImportParams(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (*EcKeyImportParams, error) { namedCurve, err := traverseObject(rt, params, "namedCurve") if err != nil { return nil, NewError(SyntaxError, "could not get namedCurve from algorithm parameter") @@ -250,7 +250,7 @@ type ECKeyGenParams struct { var _ KeyGenerator = &ECKeyGenParams{} -func newECKeyGenParams(rt *goja.Runtime, normalized Algorithm, params goja.Value) (*ECKeyGenParams, error) { +func newECKeyGenParams(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (*ECKeyGenParams, error) { namedCurve, err := traverseObject(rt, params, "namedCurve") if err != nil { return nil, NewError(SyntaxError, "could not get namedCurve from algorithm parameter") @@ -510,7 +510,7 @@ type ECDSAParams struct { Hash Algorithm } -func newECDSAParams(rt *goja.Runtime, normalized Algorithm, params goja.Value) (*ECDSAParams, error) { +func newECDSAParams(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (*ECDSAParams, error) { hashValue, err := traverseObject(rt, params, "hash") if err != nil { return nil, NewError(SyntaxError, "could not get hash from algorithm parameter") diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/encryption.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/encryption.go index 40b81a89e89..2e6d3fcb995 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/encryption.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/encryption.go @@ -3,7 +3,7 @@ package webcrypto import ( "fmt" - "github.com/dop251/goja" + "github.com/grafana/sobek" ) // Encrypter is an interface for encrypting data. @@ -23,14 +23,14 @@ type EncryptDecrypter interface { } // newEncryptDecrypter instantiates an EncryptDecrypter based on the provided -// algorithm and parameters `goja.Value`. +// algorithm and parameters `sobek.Value`. // // The returned instance can be used to encrypt/decrypt data using the // corresponding AES algorithm. func newEncryptDecrypter( - rt *goja.Runtime, + rt *sobek.Runtime, algorithm Algorithm, - params goja.Value, + params sobek.Value, ) (EncryptDecrypter, error) { var ed EncryptDecrypter var paramsObjectName string diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/errors.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/errors.go index 5c39ab6cab7..4ceb9c78d64 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/errors.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/errors.go @@ -3,7 +3,7 @@ package webcrypto // ErrorName is a type alias for the name of a WebCryptoError. // // Note that it is a type alias, and not a binding, so that it is -// not interpreted as an object by goja. +// not interpreted as an object by sobek. type ErrorName = string const ( diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/goja.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/goja.go index 8782d35f846..f651d67e149 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/goja.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/goja.go @@ -4,29 +4,29 @@ import ( "fmt" "strings" - "github.com/dop251/goja" + "github.com/grafana/sobek" "go.k6.io/k6/js/common" ) // exportArrayBuffer interprets the given value as an ArrayBuffer, TypedArray or DataView // and returns a copy of the underlying byte slice. -func exportArrayBuffer(rt *goja.Runtime, v goja.Value) ([]byte, error) { +func exportArrayBuffer(rt *sobek.Runtime, v sobek.Value) ([]byte, error) { if common.IsNullish(v) { return nil, NewError(TypeError, "data is null or undefined") } asObject := v.ToObject(rt) - var ab goja.ArrayBuffer + var ab sobek.ArrayBuffer var ok bool if IsTypedArray(rt, v) { - ab, ok = asObject.Get("buffer").Export().(goja.ArrayBuffer) + ab, ok = asObject.Get("buffer").Export().(sobek.ArrayBuffer) if !ok { return nil, NewError(TypeError, "TypedArray.buffer is not an ArrayBuffer") } } else { - ab, ok = asObject.Export().(goja.ArrayBuffer) + ab, ok = asObject.Export().(sobek.ArrayBuffer) if !ok { return nil, NewError(OperationError, "data is neither an ArrayBuffer, nor a TypedArray nor DataView") } @@ -45,7 +45,7 @@ func exportArrayBuffer(rt *goja.Runtime, v goja.Value) ([]byte, error) { // traverseObject traverses the given object using the given fields and returns the value // at the end of the traversal. It assumes that all the traversed fields are Objects. -func traverseObject(rt *goja.Runtime, src goja.Value, fields ...string) (goja.Value, error) { +func traverseObject(rt *sobek.Runtime, src sobek.Value, fields ...string) (sobek.Value, error) { if common.IsNullish(src) { return nil, NewError(TypeError, "Object is null or undefined") } @@ -78,7 +78,7 @@ func traverseObject(rt *goja.Runtime, src goja.Value, fields ...string) (goja.Va // IsInstanceOf returns true if the given value is an instance of the given constructor // This uses the technique described in https://github.com/dop251/goja/issues/379#issuecomment-1164441879 -func IsInstanceOf(rt *goja.Runtime, v goja.Value, instanceOf ...JSType) bool { +func IsInstanceOf(rt *sobek.Runtime, v sobek.Value, instanceOf ...JSType) bool { var valid bool for _, t := range instanceOf { @@ -92,7 +92,7 @@ func IsInstanceOf(rt *goja.Runtime, v goja.Value, instanceOf ...JSType) bool { } // IsTypedArray returns true if the given value is an instance of a Typed Array -func IsTypedArray(rt *goja.Runtime, v goja.Value) bool { +func IsTypedArray(rt *sobek.Runtime, v sobek.Value) bool { asObject := v.ToObject(rt) typedArrayTypes := []JSType{ diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/hmac.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/hmac.go index bc93809b472..1af3688c383 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/hmac.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/hmac.go @@ -9,7 +9,7 @@ import ( "fmt" "hash" - "github.com/dop251/goja" + "github.com/grafana/sobek" "gopkg.in/guregu/null.v3" ) @@ -44,7 +44,7 @@ func (hkgp HMACKeyGenParams) hash() string { // not present as described in the hmac `generateKey` [specification]. // // [specification]: https://www.w3.org/TR/WebCryptoAPI/#hmac-operations -func newHMACKeyGenParams(rt *goja.Runtime, normalized Algorithm, params goja.Value) (*HMACKeyGenParams, error) { +func newHMACKeyGenParams(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (*HMACKeyGenParams, error) { // The specification doesn't explicitly tell us what to do if the // hash field is not present, but we assume it's a mandatory field // and throw an error if it's not present. @@ -243,7 +243,7 @@ func (hip HMACImportParams) hash() string { // newHMACImportParams creates a new HMACImportParams object from the given // algorithm and params objects. -func newHMACImportParams(rt *goja.Runtime, normalized Algorithm, params goja.Value) (*HMACImportParams, error) { +func newHMACImportParams(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (*HMACImportParams, error) { // The specification doesn't explicitly tell us what to do if the // hash field is not present, but we assume it's a mandatory field // and throw an error if it's not present. diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/key.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/key.go index 1c8d64f9b00..421f3a3ce87 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/key.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/key.go @@ -3,7 +3,7 @@ package webcrypto import ( "errors" - "github.com/dop251/goja" + "github.com/grafana/sobek" ) // CryptoKeyGenerationResult represents the result of a key generation operation. @@ -114,7 +114,7 @@ func (ck *CryptoKey) ContainsUsage(usage CryptoKeyUsage) bool { // CryptoKeyType represents the type of a key. // // Note that it is defined as an alias of string, instead of a dedicated type, -// to ensure it is handled as a string by goja. +// to ensure it is handled as a string by sobek. type CryptoKeyType = string const ( @@ -137,7 +137,7 @@ const ( // CryptoKeyUsage represents the usage of a key. // // Note that it is defined as an alias of string, instead of a dedicated type, -// to ensure it is handled as a string by goja. +// to ensure it is handled as a string by sobek. type CryptoKeyUsage = string const ( @@ -177,7 +177,7 @@ type KeyGenerator interface { GenerateKey(extractable bool, keyUsages []CryptoKeyUsage) (CryptoKeyGenerationResult, error) } -func newKeyGenerator(rt *goja.Runtime, normalized Algorithm, params goja.Value) (KeyGenerator, error) { +func newKeyGenerator(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (KeyGenerator, error) { var kg KeyGenerator var err error @@ -205,7 +205,7 @@ type KeyImporter interface { ImportKey(format KeyFormat, keyData []byte, keyUsages []CryptoKeyUsage) (*CryptoKey, error) } -func newKeyImporter(rt *goja.Runtime, normalized Algorithm, params goja.Value) (KeyImporter, error) { +func newKeyImporter(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (KeyImporter, error) { var ki KeyImporter var err error @@ -260,7 +260,7 @@ func contains[T comparable](container []T, element T) bool { // KeyFormat represents the format of a CryptoKey. // // Note that it is defined as an alias of string, instead of a dedicated type, -// to ensure it is handled as a string by goja. +// to ensure it is handled as a string by sobek. type KeyFormat = string const ( @@ -280,7 +280,7 @@ const ( // KeyLength holds the length of the key, in bits. // // Note that it is defined as an alias of uint16, instead of a dedicated type, -// to ensure it is handled as a number by goja. +// to ensure it is handled as a number by sobek. type KeyLength = uint16 const ( diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/module.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/module.go index f82b9ccc888..c8f298d6fff 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/module.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/module.go @@ -4,7 +4,7 @@ package webcrypto import ( "fmt" - "github.com/dop251/goja" + "github.com/grafana/sobek" "go.k6.io/k6/js/common" "go.k6.io/k6/js/modules" ) @@ -47,7 +47,7 @@ func (mi *ModuleInstance) Exports() modules.Exports { }} } -func newCryptoObject(vu modules.VU) *goja.Object { +func newCryptoObject(vu modules.VU) *sobek.Object { rt := vu.Runtime() obj := rt.NewObject() @@ -77,7 +77,7 @@ func newCryptoObject(vu modules.VU) *goja.Object { return obj } -func newSubtleCryptoObject(vu modules.VU) *goja.Object { +func newSubtleCryptoObject(vu modules.VU) *sobek.Object { rt := vu.Runtime() obj := rt.NewObject() @@ -135,13 +135,13 @@ func newSubtleCryptoObject(vu modules.VU) *goja.Object { return obj } -// setReadOnlyPropertyOf sets a read-only property on the given [goja.Object]. -func setReadOnlyPropertyOf(obj *goja.Object, name string, value goja.Value) error { +// setReadOnlyPropertyOf sets a read-only property on the given [sobek.Object]. +func setReadOnlyPropertyOf(obj *sobek.Object, name string, value sobek.Value) error { err := obj.DefineDataProperty(name, value, - goja.FLAG_FALSE, - goja.FLAG_FALSE, - goja.FLAG_TRUE, + sobek.FLAG_FALSE, + sobek.FLAG_FALSE, + sobek.FLAG_TRUE, ) if err != nil { return fmt.Errorf("unable to define %s read-only property on TextEncoder object; reason: %w", name, err) diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/signer.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/signer.go index 095dd2997f6..3f8b92f542d 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/signer.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/signer.go @@ -1,6 +1,6 @@ package webcrypto -import "github.com/dop251/goja" +import "github.com/grafana/sobek" // SignerVerifier . type SignerVerifier interface { @@ -8,7 +8,7 @@ type SignerVerifier interface { Verify(key CryptoKey, signature, dataToVerify []byte) (bool, error) } -func newSignerVerifier(rt *goja.Runtime, normalized Algorithm, params goja.Value) (SignerVerifier, error) { +func newSignerVerifier(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (SignerVerifier, error) { switch normalized.Name { case HMAC: return &hmacSignerVerifier{}, nil diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/subtle_crypto.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/subtle_crypto.go index 61a5ddd4f91..7f9026bc358 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/subtle_crypto.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/subtle_crypto.go @@ -7,7 +7,7 @@ import ( "hash" "strings" - "github.com/dop251/goja" + "github.com/grafana/sobek" "go.k6.io/k6/js/common" "go.k6.io/k6/js/modules" ) @@ -39,8 +39,8 @@ type SubtleCrypto struct { // // The `data` parameter should contain the data to be encryption. func (sc *SubtleCrypto) Encrypt( //nolint:dupl // we have two similar methods - algorithm, key, data goja.Value, -) *goja.Promise { + algorithm, key, data sobek.Value, +) *sobek.Promise { rt := sc.vu.Runtime() var ( @@ -132,8 +132,8 @@ func (sc *SubtleCrypto) Encrypt( //nolint:dupl // we have two similar methods // // The `data` parameter should contain the data to be decrypted. func (sc *SubtleCrypto) Decrypt( //nolint:dupl // we have two similar methods - algorithm, key, data goja.Value, -) *goja.Promise { + algorithm, key, data sobek.Value, +) *sobek.Promise { rt := sc.vu.Runtime() var ( @@ -223,7 +223,7 @@ func (sc *SubtleCrypto) Decrypt( //nolint:dupl // we have two similar methods // `algorithm` identifies a public-key cryptosystem, this is the private key. // // The `data` parameter should contain the data to be signed. -func (sc *SubtleCrypto) Sign(algorithm, key, data goja.Value) *goja.Promise { +func (sc *SubtleCrypto) Sign(algorithm, key, data sobek.Value) *sobek.Promise { rt := sc.vu.Runtime() var ( @@ -321,7 +321,7 @@ func (sc *SubtleCrypto) Sign(algorithm, key, data goja.Value) *goja.Promise { // The `signature` parameter should contain the signature to be verified. // // The `data` parameter should contain the original signed data. -func (sc *SubtleCrypto) Verify(algorithm, key, signature, data goja.Value) *goja.Promise { +func (sc *SubtleCrypto) Verify(algorithm, key, signature, data sobek.Value) *sobek.Promise { rt := sc.vu.Runtime() var ( @@ -415,7 +415,7 @@ func (sc *SubtleCrypto) Verify(algorithm, key, signature, data goja.Value) *goja // - SHA-512 // // The `data` parameter should contain the data to be digested. -func (sc *SubtleCrypto) Digest(algorithm goja.Value, data goja.Value) *goja.Promise { +func (sc *SubtleCrypto) Digest(algorithm sobek.Value, data sobek.Value) *sobek.Promise { rt := sc.vu.Runtime() var ( @@ -496,7 +496,9 @@ func (sc *SubtleCrypto) Digest(algorithm goja.Value, data goja.Value) *goja.Prom // using `SubtleCrypto.ExportKey` or `SubtleCrypto.WrapKey`. // // The `keyUsages` parameter is an array of strings indicating what the key can be used for. -func (sc *SubtleCrypto) GenerateKey(algorithm goja.Value, extractable bool, keyUsages []CryptoKeyUsage) *goja.Promise { +func (sc *SubtleCrypto) GenerateKey( + algorithm sobek.Value, extractable bool, keyUsages []CryptoKeyUsage, +) *sobek.Promise { rt := sc.vu.Runtime() var keyGenerator KeyGenerator @@ -596,12 +598,12 @@ func (sc *SubtleCrypto) GenerateKey(algorithm goja.Value, extractable bool, keyU // //nolint:revive // remove the nolint directive when the method is implemented func (sc *SubtleCrypto) DeriveKey( - algorithm goja.Value, - baseKey goja.Value, - derivedKeyAlgorithm goja.Value, + algorithm sobek.Value, + baseKey sobek.Value, + derivedKeyAlgorithm sobek.Value, extractable bool, keyUsages []CryptoKeyUsage, -) *goja.Promise { +) *sobek.Promise { // TODO: implementation return nil } @@ -633,10 +635,10 @@ func (sc *SubtleCrypto) DeriveKey( // // The `length` parameter is the number of bits to derive. The number should be a multiple of 8. func (sc *SubtleCrypto) DeriveBits( //nolint:funlen,gocognit // we have a lot of error handling - algorithm goja.Value, - baseKey goja.Value, + algorithm sobek.Value, + baseKey sobek.Value, length int, -) *goja.Promise { +) *sobek.Promise { rt := sc.vu.Runtime() var ( @@ -776,11 +778,11 @@ func (sc *SubtleCrypto) DeriveBits( //nolint:funlen,gocognit // we have a lot of // - for HKDF: pass the string "HKDF" func (sc *SubtleCrypto) ImportKey( //nolint:funlen // we have a lot of error handling format KeyFormat, - keyData goja.Value, - algorithm goja.Value, + keyData sobek.Value, + algorithm sobek.Value, extractable bool, keyUsages []CryptoKeyUsage, -) *goja.Promise { +) *sobek.Promise { rt := sc.vu.Runtime() var ( @@ -877,8 +879,8 @@ func (sc *SubtleCrypto) ImportKey( //nolint:funlen // we have a lot of error han // The `key` parameter is the key to export, as a CryptoKey object. func (sc *SubtleCrypto) ExportKey( //nolint:funlen // we have a lot of error handling format KeyFormat, - key goja.Value, -) *goja.Promise { + key sobek.Value, +) *sobek.Promise { rt := sc.vu.Runtime() var ( @@ -996,10 +998,10 @@ func isBinaryExportedFormat(format KeyFormat) bool { //nolint:revive // remove the nolint directive when the method is implemented func (sc *SubtleCrypto) WrapKey( format KeyFormat, - key goja.Value, - wrappingKey goja.Value, - wrapAlgorithm goja.Value, -) *goja.Promise { + key sobek.Value, + wrappingKey sobek.Value, + wrapAlgorithm sobek.Value, +) *sobek.Promise { // TODO: implementation return nil } @@ -1052,12 +1054,12 @@ func (sc *SubtleCrypto) WrapKey( func (sc *SubtleCrypto) UnwrapKey( format KeyFormat, wrappedKey []byte, - unwrappingKey goja.Value, - unwrapAlgo goja.Value, - unwrappedKeyAlgo goja.Value, + unwrappingKey sobek.Value, + unwrapAlgo sobek.Value, + unwrappedKeyAlgo sobek.Value, extractable bool, keyUsages []CryptoKeyUsage, -) *goja.Promise { +) *sobek.Promise { // TODO: implementation return nil } diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/test_setup.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/test_setup.go index cd2b0004232..84d39770cf6 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/test_setup.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/test_setup.go @@ -9,7 +9,7 @@ import ( "go.k6.io/k6/js/compiler" - "github.com/dop251/goja" + "github.com/grafana/sobek" "github.com/stretchr/testify/require" k6encoding "go.k6.io/k6/js/modules/k6/encoding" "go.k6.io/k6/js/modulestest" @@ -34,7 +34,7 @@ func newConfiguredRuntime(t testing.TB) *modulestest.Runtime { ) require.NoError(t, err) - // We compile the Web Platform testharness script into a goja.Program + // We compile the Web Platform testharness script into a sobek.Program harnessProgram, err := CompileFile("./tests/util", "testharness.js") require.NoError(t, err) @@ -44,7 +44,7 @@ func newConfiguredRuntime(t testing.TB) *modulestest.Runtime { _, err = runtime.VU.Runtime().RunProgram(harnessProgram) require.NoError(t, err) - // We compile the Web Platform helpers script into a goja.Program + // We compile the Web Platform helpers script into a sobek.Program helpersProgram, err := CompileFile("./tests/util", "helpers.js") require.NoError(t, err) @@ -71,8 +71,8 @@ func newConfiguredRuntime(t testing.TB) *modulestest.Runtime { return runtime } -// CompileFile compiles a javascript file as a goja.Program. -func CompileFile(base, name string) (*goja.Program, error) { +// CompileFile compiles a javascript file as a sobek.Program. +func CompileFile(base, name string) (*sobek.Program, error) { filename := path.Join(base, name) //nolint:forbidigo // Allow os.Open in tests @@ -93,7 +93,7 @@ func CompileFile(base, name string) (*goja.Program, error) { } str := string(b) - program, err := goja.Compile(name, str, false) + program, err := sobek.Compile(name, str, false) if err != nil { return nil, err } diff --git a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/types.go b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/types.go index 73161d79e22..0591eff61e4 100644 --- a/vendor/github.com/grafana/xk6-webcrypto/webcrypto/types.go +++ b/vendor/github.com/grafana/xk6-webcrypto/webcrypto/types.go @@ -3,7 +3,7 @@ package webcrypto import ( "fmt" - "github.com/dop251/goja" + "github.com/grafana/sobek" ) // bitLength is a type alias for the length of a bits collection. @@ -29,7 +29,7 @@ func ToBytes(data interface{}) ([]byte, error) { return dt, nil case string: return []byte(dt), nil - case goja.ArrayBuffer: + case sobek.ArrayBuffer: return dt.Bytes(), nil default: return nil, fmt.Errorf("invalid type %T, expected string, []byte or ArrayBuffer", data) diff --git a/vendor/modules.txt b/vendor/modules.txt index e20c2f36189..346fa48218b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -200,8 +200,8 @@ github.com/grafana/xk6-output-prometheus-remote/pkg/stale # github.com/grafana/xk6-redis v0.2.0 ## explicit; go 1.19 github.com/grafana/xk6-redis/redis -# github.com/grafana/xk6-webcrypto v0.3.0 -## explicit; go 1.19 +# github.com/grafana/xk6-webcrypto v0.4.0 +## explicit; go 1.20 github.com/grafana/xk6-webcrypto/webcrypto # github.com/grafana/xk6-websockets v0.5.1 ## explicit; go 1.20