{"id":24862501,"url":"https://github.com/tab/smartid","last_synced_at":"2025-10-26T22:10:30.743Z","repository":{"id":274699883,"uuid":"923786072","full_name":"tab/smartid","owner":"tab","description":"Go client for the Smart-ID API","archived":false,"fork":false,"pushed_at":"2025-03-03T19:19:40.000Z","size":740,"stargazers_count":2,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T17:50:27.477Z","etag":null,"topics":["authentication","go","golang","smart-id"],"latest_commit_sha":null,"homepage":"https://tab.github.io/smartid","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-28T20:27:14.000Z","updated_at":"2025-03-03T19:40:48.000Z","dependencies_parsed_at":"2025-03-26T17:44:45.746Z","dependency_job_id":"6d1157df-c4ec-491f-b7a3-d1210bbe7a02","html_url":"https://github.com/tab/smartid","commit_stats":null,"previous_names":["tab/smart-id","tab/smartid"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tab%2Fsmartid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tab%2Fsmartid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tab%2Fsmartid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tab%2Fsmartid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tab","download_url":"https://codeload.github.com/tab/smartid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647252,"owners_count":21139081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","go","golang","smart-id"],"created_at":"2025-01-31T22:57:37.976Z","updated_at":"2025-10-26T22:10:25.706Z","avatar_url":"https://github.com/tab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Smart-ID client\n\nGolang client for the Smart-ID API (https://www.smart-id.com).\nIt is a simple wrapper around the API, which helps easily integrate Smart-ID authentication into Golang applications.\n\n## Features\n\n- Flexible client configuration\n- Concurrent processing\n- Optional TLS configuration (certificate pinning)\n\n## Installation\n\nUse `go get` to install the package\n\n```sh\ngo get -u github.com/tab/smartid\n```\n\n## Usage\n\n### Creating a Client\n\nCreate a new client using `NewClient()` and customize its configuration using chainable methods.\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"log\"\n  \"time\"\n\n  \"github.com/tab/smartid\"\n)\n\nfunc main() {\n  client := smartid.NewClient().\n    WithRelyingPartyName(\"DEMO\").\n    WithRelyingPartyUUID(\"00000000-0000-0000-0000-000000000000\").\n    WithCertificateLevel(\"QUALIFIED\").\n    WithHashType(\"SHA512\").\n    WithInteractionType(\"displayTextAndPIN\").\n    WithDisplayText60(\"Enter PIN1\").\n    WithDisplayText200(\"Confirm the authentication request and enter PIN1\").\n    WithURL(\"https://sid.demo.sk.ee/smart-id-rp/v2\").\n    WithTimeout(60 * time.Second)\n\n  if err := client.Validate(); err != nil {\n    log.Fatal(\"Invalid configuration:\", err)\n  }\n\n  // Further processing...\n}\n```\n\n### Start Authentication\n\nInitiate a new authentication session with the `Smart-ID` provider by calling `CreateSession`.\nThis function generates a random hash, constructs the session request, and returns a session that includes an identifier and a verification code.\n\n```go\nfunc main() {\n  // Create a client...\n\n  identity := smartid.NewIdentity(smartid.TypePNO, \"EE\", \"30303039914\")\n\n  session, err := client.CreateSession(context.Background(), identity)\n  if err != nil {\n    log.Fatal(\"Error creating session:\", err)\n  }\n\n  fmt.Println(\"Session created:\", session)\n}\n```\n\n### Fetch Session\n\n```go\nfunc main() {\n  // Create a client...\n\n  person, err := client.FetchSession(context.Background(), sessionId)\n  if err != nil {\n    log.Fatal(\"Error fetching session:\", err)\n  }\n\n  fmt.Println(\"Session status:\", session.State)\n}\n```\n\n### Async Example\n\nFor applications requiring the processing of multiple authentication sessions simultaneously, `Smart-ID` provides a worker model.\nCreate a worker using `NewWorker`, configure its concurrency and queue size, and then start processing.\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"fmt\"\n  \"log\"\n  \"sync\"\n  \"time\"\n\n  \"github.com/tab/smartid\"\n)\n\nfunc main() {\n  client := smartid.NewClient().\n    WithRelyingPartyName(\"DEMO\").\n    WithRelyingPartyUUID(\"00000000-0000-0000-0000-000000000000\").\n    WithCertificateLevel(\"QUALIFIED\").\n    WithHashType(\"SHA512\").\n    WithInteractionType(\"displayTextAndPIN\").\n    WithDisplayText60(\"Enter PIN1\").\n    WithDisplayText200(\"Confirm the authentication request and enter PIN1\").\n    WithURL(\"https://sid.demo.sk.ee/smart-id-rp/v2\").\n    WithTimeout(60 * time.Second)\n\n  identities := []string{\n    smartid.NewIdentity(smartid.TypePNO, \"EE\", \"30303039914\"),\n    smartid.NewIdentity(smartid.TypePNO, \"EE\", \"30403039917\"),\n    smartid.NewIdentity(smartid.TypePNO, \"EE\", \"30403039928\"),\n    // Add more identities as needed\n  }\n\n  worker := smartid.NewWorker(client).\n    WithConcurrency(50).\n    WithQueueSize(100)\n\n  ctx := context.Background()\n  worker.Start(ctx)\n  defer worker.Stop()\n\n  var wg sync.WaitGroup\n\n  for _, identity := range identities {\n    wg.Add(1)\n\n    session, err := client.CreateSession(ctx, identity)\n    if err != nil {\n      log.Println(\"Error creating session:\", err)\n      wg.Done()\n      continue\n    }\n    fmt.Println(\"Session created:\", session)\n\n    resultCh := worker.Process(ctx, session.Id)\n    go func() {\n      defer wg.Done()\n      result := \u003c-resultCh\n      if result.Err != nil {\n        log.Println(\"Error fetching session:\", result.Err)\n      } else {\n        fmt.Println(\"Fetched person:\", result.Person)\n      }\n    }()\n  }\n\n  wg.Wait()\n}\n```\n\n### Certificate pinning (optional)\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"fmt\"\n  \"sync\"\n  \"time\"\n\n  \"github.com/tab/smartid\"\n)\n\nfunc main() {\n  manager, err := smartid.NewCertificateManager(\"./certs\")\n  if err != nil {\n    fmt.Println(\"Failed to create certificate manager:\", err)\n  }\n  tlsConfig := manager.TLSConfig()\n\n  client := smartid.NewClient().\n    WithRelyingPartyName(\"DEMO\").\n    WithRelyingPartyUUID(\"00000000-0000-0000-0000-000000000000\").\n    WithCertificateLevel(\"QUALIFIED\").\n    WithHashType(\"SHA512\").\n    WithInteractionType(\"displayTextAndPIN\").\n    WithDisplayText60(\"Enter PIN1\").\n    WithDisplayText200(\"Confirm the authentication request and enter PIN1\").\n    WithURL(\"https://sid.demo.sk.ee/smart-id-rp/v2\").\n    WithTimeout(60 * time.Second).\n    WithTLSConfig(tlsConfig)\n\n  // Further processing...\n```\n\n### Prepare Identity\n\nSmart-ID requires a properly formatted identity string. Use the `NewIdentity` function to create this string.\nIt combines the identity type, country code, and the identifier value.\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n\n  \"github.com/tab/smartid\"\n)\n\nfunc main() {\n  identity := smartid.NewIdentity(smartid.TypePNO, \"EE\", \"30303039914\")\n  fmt.Println(\"Formatted identity:\", identity)\n}\n```\n\n## Documentation\n\n- [Documentation](https://tab.github.io/smartid)\n- [GoDoc](https://pkg.go.dev/github.com/tab/smartid)\n- [Smart-ID Documentation](https://github.com/SK-EID/smart-id-documentation)\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n## Acknowledgements\n\n- [SK ID Solutions](https://www.skidsolutions.eu)\n- [Smart-ID](https://www.smart-id.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftab%2Fsmartid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftab%2Fsmartid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftab%2Fsmartid/lists"}