Documentation ¶
Index ¶
- Constants
- Variables
- type Policy
- type PolicyBuilder
- func (b *PolicyBuilder) Build() (Policy, error)
- func (b *PolicyBuilder) WithAdvancedIdentityProfileRequirements(advancedIdentityProfile json.RawMessage) *PolicyBuilder
- func (b *PolicyBuilder) WithAgeDerivedAttribute(derivation string, options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithAgeOver(age int, options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithAgeUnder(age int, options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithDateOfBirth(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithDocumentDetails(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithDocumentImages(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithEmail(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithFamilyName(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithFullName(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithGender(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithGivenNames(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithIdentityProfileRequirements(identityProfile json.RawMessage) *PolicyBuilder
- func (b *PolicyBuilder) WithNationality(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithPhoneNumber(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithPinAuth() *PolicyBuilder
- func (b *PolicyBuilder) WithPostalAddress(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithSelfie(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithSelfieAuth() *PolicyBuilder
- func (b *PolicyBuilder) WithStructuredPostalAddress(options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithWantedAttribute(attribute WantedAttribute) *PolicyBuilder
- func (b *PolicyBuilder) WithWantedAttributeByName(name string, options ...interface{}) *PolicyBuilder
- func (b *PolicyBuilder) WithWantedAuthType(wantedAuthType int) *PolicyBuilder
- func (b *PolicyBuilder) WithWantedRememberMe() *PolicyBuilder
- type Scenario
- type ScenarioBuilder
- func (builder *ScenarioBuilder) Build() (Scenario, error)
- func (builder *ScenarioBuilder) WithCallbackEndpoint(endpoint string) *ScenarioBuilder
- func (builder *ScenarioBuilder) WithExtension(extension interface{}) *ScenarioBuilder
- func (builder *ScenarioBuilder) WithPolicy(policy Policy) *ScenarioBuilder
- func (builder *ScenarioBuilder) WithSubject(subject json.RawMessage) *ScenarioBuilder
- type ShareURL
- type SourceConstraint
- type SourceConstraintBuilder
- func (b *SourceConstraintBuilder) Build() (SourceConstraint, error)
- func (b *SourceConstraintBuilder) WithAnchor(anchor WantedAnchor) *SourceConstraintBuilder
- func (b *SourceConstraintBuilder) WithAnchorByValue(value, subtype string) *SourceConstraintBuilder
- func (b *SourceConstraintBuilder) WithDrivingLicence(subtype string) *SourceConstraintBuilder
- func (b *SourceConstraintBuilder) WithNationalID(subtype string) *SourceConstraintBuilder
- func (b *SourceConstraintBuilder) WithPasscard(subtype string) *SourceConstraintBuilder
- func (b *SourceConstraintBuilder) WithPassport(subtype string) *SourceConstraintBuilder
- func (b *SourceConstraintBuilder) WithSoftPreference(soft bool) *SourceConstraintBuilder
- type WantedAnchor
- type WantedAnchorBuilder
- type WantedAttribute
- type WantedAttributeBuilder
- func (builder *WantedAttributeBuilder) Build() (WantedAttribute, error)
- func (builder *WantedAttributeBuilder) WithAcceptSelfAsserted(accept bool) *WantedAttributeBuilder
- func (builder *WantedAttributeBuilder) WithConstraint(constraint constraintInterface) *WantedAttributeBuilder
- func (builder *WantedAttributeBuilder) WithDerivation(derivation string) *WantedAttributeBuilder
- func (builder *WantedAttributeBuilder) WithName(name string) *WantedAttributeBuilder
Examples ¶
- CreateShareURL
- PolicyBuilder
- PolicyBuilder.WithAdvancedIdentityProfileRequirements
- PolicyBuilder.WithAgeOver
- PolicyBuilder.WithAgeUnder
- PolicyBuilder.WithDateOfBirth
- PolicyBuilder.WithDocumentDetails
- PolicyBuilder.WithDocumentImages
- PolicyBuilder.WithFamilyName
- PolicyBuilder.WithFullName
- PolicyBuilder.WithGender
- PolicyBuilder.WithGivenNames
- PolicyBuilder.WithIdentityProfileRequirements
- PolicyBuilder.WithNationality
- PolicyBuilder.WithPhoneNumber
- PolicyBuilder.WithPostalAddress
- PolicyBuilder.WithSelfie
- PolicyBuilder.WithSelfieAuth
- PolicyBuilder.WithStructuredPostalAddress
- PolicyBuilder.WithWantedRememberMe
- ScenarioBuilder
- ScenarioBuilder.WithExtension
- ScenarioBuilder.WithPolicy
- ScenarioBuilder.WithSubject
- SourceConstraint
- SourceConstraintBuilder.WithDrivingLicence
- SourceConstraintBuilder.WithNationalID
- SourceConstraintBuilder.WithPasscard
- SourceConstraintBuilder.WithPassport
- WantedAnchorBuilder
- WantedAttributeBuilder (Optional_true)
- WantedAttributeBuilder.WithAcceptSelfAsserted
- WantedAttributeBuilder.WithAcceptSelfAsserted (False)
- WantedAttributeBuilder.WithConstraint
- WantedAttributeBuilder.WithDerivation
- WantedAttributeBuilder.WithName
Constants ¶
const ( AnchorDrivingLicenceConst = "DRIVING_LICENCE" AnchorPassportConst = "PASSPORT" AnchorNationalIDConst = "NATIONAL_ID" AnchorPassCardConst = "PASS_CARD" )
Anchor name constants
Variables ¶
var ( // by the Share URL API ShareURLHTTPErrorMessages = map[int]string{ 400: "JSON is incorrect, contains invalid data", 404: "Application was not found", } )
Functions ¶
This section is empty.
Types ¶
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy represents a dynamic policy for a share
func (*Policy) MarshalJSON ¶
MarshalJSON returns the JSON encoding
type PolicyBuilder ¶
type PolicyBuilder struct {
// contains filtered or unexported fields
}
PolicyBuilder constructs a json payload specifying the dynamic policy for a dynamic scenario
Example ¶
policy, err := (&PolicyBuilder{}).WithFullName(). WithPinAuth().WithWantedRememberMe().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[{"name":"full_name","accept_self_asserted":false}],"wanted_auth_types":[2],"wanted_remember_me":true}
func (*PolicyBuilder) Build ¶
func (b *PolicyBuilder) Build() (Policy, error)
Build constructs a dynamic policy object
func (*PolicyBuilder) WithAdvancedIdentityProfileRequirements ¶ added in v3.11.0
func (b *PolicyBuilder) WithAdvancedIdentityProfileRequirements(advancedIdentityProfile json.RawMessage) *PolicyBuilder
WithAdvancedIdentityProfileRequirements adds Advanced Identity Profile Requirements to the policy. Must be valid JSON.
Example ¶
advancedIdentityProfile := []byte(`{ "profiles": [ { "trust_framework": "UK_TFIDA", "schemes": [ { "label": "LB912", "type": "RTW" }, { "label": "LB777", "type": "DBS", "objective": "BASIC" } ] }, { "trust_framework": "YOTI_GLOBAL", "schemes": [ { "label": "LB321", "type": "IDENTITY", "objective": "AL_L1", "config": {} } ] } ] }`) policy, err := (&PolicyBuilder{}).WithAdvancedIdentityProfileRequirements(advancedIdentityProfile).Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[],"wanted_auth_types":[],"wanted_remember_me":false,"advanced_identity_profile_requirements":{"profiles":[{"trust_framework":"UK_TFIDA","schemes":[{"label":"LB912","type":"RTW"},{"label":"LB777","type":"DBS","objective":"BASIC"}]},{"trust_framework":"YOTI_GLOBAL","schemes":[{"label":"LB321","type":"IDENTITY","objective":"AL_L1","config":{}}]}]}}
func (*PolicyBuilder) WithAgeDerivedAttribute ¶
func (b *PolicyBuilder) WithAgeDerivedAttribute(derivation string, options ...interface{}) *PolicyBuilder
WithAgeDerivedAttribute is a helper method for setting age based derivations Prefer to use WithAgeOver and WithAgeUnder instead of using this directly. "options" allows one or more options to be specified e.g. SourceConstraint
func (*PolicyBuilder) WithAgeOver ¶
func (b *PolicyBuilder) WithAgeOver(age int, options ...interface{}) *PolicyBuilder
WithAgeOver sets this dynamic policy as requesting whether the user is older than a certain age. "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
constraint, err := (&SourceConstraintBuilder{}).WithDrivingLicence("").Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } policy, err := (&PolicyBuilder{}).WithAgeOver(18, constraint).Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.attributes[0].MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"name":"date_of_birth","derivation":"age_over:18","constraints":[{"type":"SOURCE","preferred_sources":{"anchors":[{"name":"DRIVING_LICENCE","sub_type":""}],"soft_preference":false}}],"accept_self_asserted":false}
func (*PolicyBuilder) WithAgeUnder ¶
func (b *PolicyBuilder) WithAgeUnder(age int, options ...interface{}) *PolicyBuilder
WithAgeUnder sets this dynamic policy as requesting whether the user is younger than a certain age, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithAgeUnder(18).Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[{"name":"date_of_birth","derivation":"age_under:18","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}
func (*PolicyBuilder) WithDateOfBirth ¶
func (b *PolicyBuilder) WithDateOfBirth(options ...interface{}) *PolicyBuilder
WithDateOfBirth adds the date of birth attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithDateOfBirth().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[{"name":"date_of_birth","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}
func (*PolicyBuilder) WithDocumentDetails ¶
func (b *PolicyBuilder) WithDocumentDetails(options ...interface{}) *PolicyBuilder
WithDocumentDetails adds the document details attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithDocumentDetails().Build() if err != nil { return } data, err := policy.attributes[0].MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"name":"document_details","accept_self_asserted":false}
func (*PolicyBuilder) WithDocumentImages ¶
func (b *PolicyBuilder) WithDocumentImages(options ...interface{}) *PolicyBuilder
WithDocumentImages adds the document images attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithDocumentImages().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.attributes[0].MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"name":"document_images","accept_self_asserted":false}
func (*PolicyBuilder) WithEmail ¶
func (b *PolicyBuilder) WithEmail(options ...interface{}) *PolicyBuilder
WithEmail adds the email address attribute, "options" allows one or more options to be specified e.g. SourceConstraint
func (*PolicyBuilder) WithFamilyName ¶
func (b *PolicyBuilder) WithFamilyName(options ...interface{}) *PolicyBuilder
WithFamilyName adds the family name attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithFamilyName().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.attributes[0].MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"name":"family_name","accept_self_asserted":false}
func (*PolicyBuilder) WithFullName ¶
func (b *PolicyBuilder) WithFullName(options ...interface{}) *PolicyBuilder
WithFullName adds the full name attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
constraint, err := (&SourceConstraintBuilder{}).WithPassport("").Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } policy, err := (&PolicyBuilder{}).WithFullName(&constraint).Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } marshalledJSON, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(marshalledJSON))
Output: {"wanted":[{"name":"full_name","constraints":[{"type":"SOURCE","preferred_sources":{"anchors":[{"name":"PASSPORT","sub_type":""}],"soft_preference":false}}],"accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}
func (*PolicyBuilder) WithGender ¶
func (b *PolicyBuilder) WithGender(options ...interface{}) *PolicyBuilder
WithGender adds the gender attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithGender().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[{"name":"gender","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}
func (*PolicyBuilder) WithGivenNames ¶
func (b *PolicyBuilder) WithGivenNames(options ...interface{}) *PolicyBuilder
WithGivenNames adds the given names attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithGivenNames().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[{"name":"given_names","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}
func (*PolicyBuilder) WithIdentityProfileRequirements ¶ added in v3.6.0
func (b *PolicyBuilder) WithIdentityProfileRequirements(identityProfile json.RawMessage) *PolicyBuilder
WithIdentityProfileRequirements adds Identity Profile Requirements to the policy. Must be valid JSON.
Example ¶
identityProfile := []byte(`{ "trust_framework": "UK_TFIDA", "scheme": { "type": "DBS", "objective": "STANDARD" } }`) policy, err := (&PolicyBuilder{}).WithIdentityProfileRequirements(identityProfile).Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[],"wanted_auth_types":[],"wanted_remember_me":false,"identity_profile_requirements":{"trust_framework":"UK_TFIDA","scheme":{"type":"DBS","objective":"STANDARD"}}}
func (*PolicyBuilder) WithNationality ¶
func (b *PolicyBuilder) WithNationality(options ...interface{}) *PolicyBuilder
WithNationality adds the nationality attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithNationality().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[{"name":"nationality","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}
func (*PolicyBuilder) WithPhoneNumber ¶
func (b *PolicyBuilder) WithPhoneNumber(options ...interface{}) *PolicyBuilder
WithPhoneNumber adds the phone number attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithPhoneNumber().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[{"name":"phone_number","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}
func (*PolicyBuilder) WithPinAuth ¶
func (b *PolicyBuilder) WithPinAuth() *PolicyBuilder
WithPinAuth sets this dynamic policy as requiring PIN authentication
func (*PolicyBuilder) WithPostalAddress ¶
func (b *PolicyBuilder) WithPostalAddress(options ...interface{}) *PolicyBuilder
WithPostalAddress adds the postal address attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithPostalAddress().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[{"name":"postal_address","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}
func (*PolicyBuilder) WithSelfie ¶
func (b *PolicyBuilder) WithSelfie(options ...interface{}) *PolicyBuilder
WithSelfie adds the selfie attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithSelfie().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.attributes[0].MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"name":"selfie","accept_self_asserted":false}
func (*PolicyBuilder) WithSelfieAuth ¶
func (b *PolicyBuilder) WithSelfieAuth() *PolicyBuilder
WithSelfieAuth sets this dynamic policy as requiring Selfie-based authentication
Example ¶
policy, err := (&PolicyBuilder{}).WithSelfieAuth().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[],"wanted_auth_types":[1],"wanted_remember_me":false}
func (*PolicyBuilder) WithStructuredPostalAddress ¶
func (b *PolicyBuilder) WithStructuredPostalAddress(options ...interface{}) *PolicyBuilder
WithStructuredPostalAddress adds the structured postal address attribute, "options" allows one or more options to be specified e.g. SourceConstraint
Example ¶
policy, err := (&PolicyBuilder{}).WithStructuredPostalAddress().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[{"name":"structured_postal_address","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}
func (*PolicyBuilder) WithWantedAttribute ¶
func (b *PolicyBuilder) WithWantedAttribute(attribute WantedAttribute) *PolicyBuilder
WithWantedAttribute adds an attribute from WantedAttributeBuilder to the policy
func (*PolicyBuilder) WithWantedAttributeByName ¶
func (b *PolicyBuilder) WithWantedAttributeByName(name string, options ...interface{}) *PolicyBuilder
WithWantedAttributeByName adds an attribute by its name. This is not the preferred way of adding an attribute - instead use the other methods below. Options allows one or more options to be specified e.g. SourceConstraint
func (*PolicyBuilder) WithWantedAuthType ¶
func (b *PolicyBuilder) WithWantedAuthType(wantedAuthType int) *PolicyBuilder
WithWantedAuthType sets this dynamic policy as requiring a specific authentication type
func (*PolicyBuilder) WithWantedRememberMe ¶
func (b *PolicyBuilder) WithWantedRememberMe() *PolicyBuilder
WithWantedRememberMe sets the Policy as requiring a "Remember Me ID"
Example ¶
policy, err := (&PolicyBuilder{}).WithWantedRememberMe().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := policy.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"wanted":[],"wanted_auth_types":[],"wanted_remember_me":true}
type Scenario ¶
type Scenario struct {
// contains filtered or unexported fields
}
Scenario represents a dynamic scenario
func (Scenario) MarshalJSON ¶
MarshalJSON returns the JSON encoding
type ScenarioBuilder ¶
type ScenarioBuilder struct {
// contains filtered or unexported fields
}
ScenarioBuilder builds a dynamic scenario
Example ¶
scenario, err := (&ScenarioBuilder{}).Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := scenario.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"policy":{"wanted":[],"wanted_auth_types":[],"wanted_remember_me":false},"extensions":[],"callback_endpoint":""}
func (*ScenarioBuilder) Build ¶
func (builder *ScenarioBuilder) Build() (Scenario, error)
Build constructs the DynamicScenario
func (*ScenarioBuilder) WithCallbackEndpoint ¶
func (builder *ScenarioBuilder) WithCallbackEndpoint(endpoint string) *ScenarioBuilder
WithCallbackEndpoint sets the callback URL
func (*ScenarioBuilder) WithExtension ¶
func (builder *ScenarioBuilder) WithExtension(extension interface{}) *ScenarioBuilder
WithExtension adds an extension to the scenario
Example ¶
policy, err := (&PolicyBuilder{}).WithFullName().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } builtExtension, err := (&extension.TransactionalFlowExtensionBuilder{}). WithContent("Transactional Flow Extension"). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } scenario, err := (&ScenarioBuilder{}).WithExtension(builtExtension).WithPolicy(policy).Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := scenario.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"policy":{"wanted":[{"name":"full_name","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false},"extensions":[{"type":"TRANSACTIONAL_FLOW","content":"Transactional Flow Extension"}],"callback_endpoint":""}
func (*ScenarioBuilder) WithPolicy ¶
func (builder *ScenarioBuilder) WithPolicy(policy Policy) *ScenarioBuilder
WithPolicy attaches a DynamicPolicy to the DynamicScenario
Example ¶
policy, err := (&PolicyBuilder{}).WithEmail().WithPinAuth().Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } scenario, err := (&ScenarioBuilder{}).WithPolicy(policy).WithCallbackEndpoint("/foo").Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := scenario.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"policy":{"wanted":[{"name":"email_address","accept_self_asserted":false}],"wanted_auth_types":[2],"wanted_remember_me":false},"extensions":[],"callback_endpoint":"/foo"}
func (*ScenarioBuilder) WithSubject ¶ added in v3.6.0
func (builder *ScenarioBuilder) WithSubject(subject json.RawMessage) *ScenarioBuilder
WithSubject adds a subject to the scenario. Must be valid JSON.
Example ¶
subject := []byte(`{ "subject_id": "some_subject_id_string" }`) scenario, err := (&ScenarioBuilder{}).WithSubject(subject).WithCallbackEndpoint("/foo").Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } data, err := scenario.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(data))
Output: {"policy":{"wanted":[],"wanted_auth_types":[],"wanted_remember_me":false},"extensions":[],"callback_endpoint":"/foo","subject":{"subject_id":"some_subject_id_string"}}
type ShareURL ¶
type ShareURL struct {}
ShareURL contains a dynamic share QR code
func CreateShareURL ¶
func CreateShareURL(httpClient requests.HttpClient, scenario *Scenario, clientSdkId, apiUrl string, key *rsa.PrivateKey) (share ShareURL, err error)
CreateShareURL creates a QR code for a dynamic scenario
type SourceConstraint ¶
type SourceConstraint struct {
// contains filtered or unexported fields
}
SourceConstraint describes a requirement or preference for a particular set of anchors
Example ¶
drivingLicence, err := (&WantedAnchorBuilder{}).WithValue("DRIVING_LICENCE").Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } sourceConstraint, err := (&SourceConstraintBuilder{}). WithAnchor(drivingLicence). WithSoftPreference(true). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } json, err := sourceConstraint.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println("SourceConstraint:", string(json))
Output: SourceConstraint: {"type":"SOURCE","preferred_sources":{"anchors":[{"name":"DRIVING_LICENCE","sub_type":""}],"soft_preference":true}}
func (*SourceConstraint) MarshalJSON ¶
func (constraint *SourceConstraint) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding
type SourceConstraintBuilder ¶
type SourceConstraintBuilder struct {
// contains filtered or unexported fields
}
SourceConstraintBuilder builds a source constraint
func (*SourceConstraintBuilder) Build ¶
func (b *SourceConstraintBuilder) Build() (SourceConstraint, error)
Build builds a SourceConstraint
func (*SourceConstraintBuilder) WithAnchor ¶
func (b *SourceConstraintBuilder) WithAnchor(anchor WantedAnchor) *SourceConstraintBuilder
WithAnchor adds an anchor to the preference list
func (*SourceConstraintBuilder) WithAnchorByValue ¶
func (b *SourceConstraintBuilder) WithAnchorByValue(value, subtype string) *SourceConstraintBuilder
WithAnchorByValue is a helper method which builds an anchor and adds it to the source constraint
func (*SourceConstraintBuilder) WithDrivingLicence ¶
func (b *SourceConstraintBuilder) WithDrivingLicence(subtype string) *SourceConstraintBuilder
WithDrivingLicence adds a Driving Licence anchor
Example ¶
sourceConstraint, err := (&SourceConstraintBuilder{}). WithDrivingLicence(""). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } json, err := sourceConstraint.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(json))
Output: {"type":"SOURCE","preferred_sources":{"anchors":[{"name":"DRIVING_LICENCE","sub_type":""}],"soft_preference":false}}
func (*SourceConstraintBuilder) WithNationalID ¶
func (b *SourceConstraintBuilder) WithNationalID(subtype string) *SourceConstraintBuilder
WithNationalID adds a national ID anchor
Example ¶
sourceConstraint, err := (&SourceConstraintBuilder{}). WithNationalID(""). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } json, err := sourceConstraint.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(json))
Output: {"type":"SOURCE","preferred_sources":{"anchors":[{"name":"NATIONAL_ID","sub_type":""}],"soft_preference":false}}
func (*SourceConstraintBuilder) WithPasscard ¶
func (b *SourceConstraintBuilder) WithPasscard(subtype string) *SourceConstraintBuilder
WithPasscard adds a passcard anchor
Example ¶
sourceConstraint, err := (&SourceConstraintBuilder{}). WithPasscard(""). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } json, err := sourceConstraint.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(json))
Output: {"type":"SOURCE","preferred_sources":{"anchors":[{"name":"PASS_CARD","sub_type":""}],"soft_preference":false}}
func (*SourceConstraintBuilder) WithPassport ¶
func (b *SourceConstraintBuilder) WithPassport(subtype string) *SourceConstraintBuilder
WithPassport adds a passport anchor
Example ¶
sourceConstraint, err := (&SourceConstraintBuilder{}). WithPassport(""). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } json, err := sourceConstraint.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(json))
Output: {"type":"SOURCE","preferred_sources":{"anchors":[{"name":"PASSPORT","sub_type":""}],"soft_preference":false}}
func (*SourceConstraintBuilder) WithSoftPreference ¶
func (b *SourceConstraintBuilder) WithSoftPreference(soft bool) *SourceConstraintBuilder
WithSoftPreference sets this constraint as a 'soft requirement' if the parameter is true, and a hard requirement if it is false.
type WantedAnchor ¶
type WantedAnchor struct {
// contains filtered or unexported fields
}
WantedAnchor specifies a preferred anchor for a user's details
func (*WantedAnchor) MarshalJSON ¶
func (a *WantedAnchor) MarshalJSON() ([]byte, error)
MarshalJSON ...
type WantedAnchorBuilder ¶
type WantedAnchorBuilder struct {
// contains filtered or unexported fields
}
WantedAnchorBuilder describes a desired anchor for user profile data
Example ¶
aadhaarAnchor, err := (&WantedAnchorBuilder{}). WithValue("NATIONAL_ID"). WithSubType("AADHAAR"). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } aadhaarJSON, err := aadhaarAnchor.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println("Aadhaar:", string(aadhaarJSON))
Output: Aadhaar: {"name":"NATIONAL_ID","sub_type":"AADHAAR"}
func (*WantedAnchorBuilder) Build ¶
func (b *WantedAnchorBuilder) Build() (WantedAnchor, error)
Build constructs the anchor from the builder's specification
func (*WantedAnchorBuilder) WithSubType ¶
func (b *WantedAnchorBuilder) WithSubType(subType string) *WantedAnchorBuilder
WithSubType sets the anchors subtype
func (*WantedAnchorBuilder) WithValue ¶
func (b *WantedAnchorBuilder) WithValue(name string) *WantedAnchorBuilder
WithValue sets the anchor's name
type WantedAttribute ¶
type WantedAttribute struct { Optional bool // contains filtered or unexported fields }
WantedAttribute represents a wanted attribute in a dynamic sharing policy
func (*WantedAttribute) MarshalJSON ¶
func (attr *WantedAttribute) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding
type WantedAttributeBuilder ¶
type WantedAttributeBuilder struct {
// contains filtered or unexported fields
}
WantedAttributeBuilder generates the payload for specifying a single wanted attribute as part of a dynamic scenario
Example (Optional_true) ¶
attribute, err := (&WantedAttributeBuilder{}). WithName("TEST NAME"). WithAcceptSelfAsserted(false). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } attribute.Optional = true marshalledJSON, err := attribute.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(marshalledJSON))
Output: {"name":"TEST NAME","accept_self_asserted":false,"optional":true}
func (*WantedAttributeBuilder) Build ¶
func (builder *WantedAttributeBuilder) Build() (WantedAttribute, error)
Build generates the wanted attribute's specification
func (*WantedAttributeBuilder) WithAcceptSelfAsserted ¶
func (builder *WantedAttributeBuilder) WithAcceptSelfAsserted(accept bool) *WantedAttributeBuilder
WithAcceptSelfAsserted allows self-asserted user details, such as those from Aadhar
Example ¶
attribute, err := (&WantedAttributeBuilder{}). WithName("TEST NAME"). WithAcceptSelfAsserted(true). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } marshalledJSON, err := attribute.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(marshalledJSON))
Output: {"name":"TEST NAME","accept_self_asserted":true}
Example (False) ¶
attribute, err := (&WantedAttributeBuilder{}). WithName("TEST NAME"). WithAcceptSelfAsserted(false). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } marshalledJSON, err := attribute.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(marshalledJSON))
Output: {"name":"TEST NAME","accept_self_asserted":false}
func (*WantedAttributeBuilder) WithConstraint ¶
func (builder *WantedAttributeBuilder) WithConstraint(constraint constraintInterface) *WantedAttributeBuilder
WithConstraint adds a constraint to a wanted attribute
Example ¶
constraint, err := (&SourceConstraintBuilder{}). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } attribute, err := (&WantedAttributeBuilder{}). WithName("TEST NAME"). WithConstraint(&constraint). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } marshalledJSON, err := attribute.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(marshalledJSON))
Output: {"name":"TEST NAME","constraints":[{"type":"SOURCE","preferred_sources":{"anchors":[],"soft_preference":false}}],"accept_self_asserted":false}
func (*WantedAttributeBuilder) WithDerivation ¶
func (builder *WantedAttributeBuilder) WithDerivation(derivation string) *WantedAttributeBuilder
WithDerivation sets the derivation
Example ¶
attribute, err := (&WantedAttributeBuilder{}). WithDerivation("TEST DERIVATION"). WithName("TEST NAME"). Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(attribute.derivation)
Output: TEST DERIVATION
func (*WantedAttributeBuilder) WithName ¶
func (builder *WantedAttributeBuilder) WithName(name string) *WantedAttributeBuilder
WithName sets the name of the wanted attribute
Example ¶
builder := (&WantedAttributeBuilder{}).WithName("TEST NAME") attribute, err := builder.Build() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(attribute.name)
Output: TEST NAME