ory / kratos

Next-gen identity server replacing your Auth0, Okta, Firebase with hardened security and PassKeys, SMS, OIDC, Social Sign In, MFA, FIDO, TOTP and OTP, WebAuthn, passwordless and much more. Golang, headless, API-first. Available as a worry-free SaaS with the fairest pricing on the market!
https://www.ory.sh/kratos/?utm_source=github&utm_medium=banner&utm_campaign=kratos
Apache License 2.0
10.82k stars 935 forks source link

jsonschema outdated tel validation #3933

Closed vmari closed 4 weeks ago

vmari commented 1 month ago

Preflight checklist

Ory Network Project

No response

Describe the bug

jsonschema schema validation is failing when using a valid phone number.

Debugging we've found that github.com/nyaruka/phonenumbers v1.1.6 is being used under the hood.

Issue is solved using latest phonenumbers version that is v1.3.5. We've tested it locally.

Please update this dependency to access latest phone validation features. It's affecting phone validation due to outdated rules even when phone format is valid.

Reproducing the bug

Here is a small code that reproduces the issue:

phone.go:

package main

import (
    "fmt"

    "github.com/nyaruka/phonenumbers"
)

func isPhone(v interface{}) bool {
  num, ok := v.(string)
    if !ok {
    return false
    }

    phoneNumber, err := phonenumbers.Parse(num, "")
    if err != nil {
    fmt.Println("Error parsing phone number: %v", err)
    return false
    }

  valid := phonenumbers.IsValidNumber(phoneNumber)

    if !valid {
    fmt.Println("Invalid phone number: %v", num)
    return false
    }

  fmt.Println("OK")
    return true
}

func main() { 
  isPhone("+16453331111")
}

go.mod:

module main

go 1.22.3

require github.com/nyaruka/phonenumbers v1.3.5

require (
    golang.org/x/text v0.14.0 // indirect
    google.golang.org/protobuf v1.33.0 // indirect
)

Here's the output:

image

Relevant log output

No response

Relevant configuration

No response

Version

v1.1.0

On which operating system are you observing this issue?

None

In which environment are you deploying?

None

Additional Context

No response