TBD54566975 / web5-go

Apache License 2.0
10 stars 6 forks source link

Duplicate jws.Sign variadic parameter options functions #98

Open KendallWeihe opened 7 months ago

KendallWeihe commented 7 months ago

These three functions in jws/jws.go are all semantically equivalent. Albeit the first two are identical function signatures so we can definitely remove one, but the third is a different signature but the same functionality, consider narrowing this down to a single function.

// Purpose is an option that can be passed to [github.com/tbd54566975/web5-go/jws.Sign].
// It is used to select the appropriate key to sign with
func Purpose(p string) SignOpt {
    return func(opts *signOpts) {
        opts.selector = didcore.Purpose(p)
    }
}

// VerificationMethod is an option that can be passed to [github.com/tbd54566975/web5-go/jws.Sign].
// It is used to select the appropriate key to sign with
func VerificationMethod(id string) SignOpt {
    return func(opts *signOpts) {
        opts.selector = didcore.ID(id)
    }
}

// VMSelector is an option that can be passed to [github.com/tbd54566975/web5-go/jws.Sign].
// It is used to select the appropriate key to sign with
func VMSelector(selector didcore.VMSelector) SignOpt {
    return func(opts *signOpts) {
        opts.selector = selector
    }
}