GithubHelp home page GithubHelp logo

sivertjoe / signicat-net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from signicat/signicat-net

0.0 0.0 0.0 1.97 MB

.NET SDK for Signicat APIs

License: Apache License 2.0

C# 99.53% PowerShell 0.47%

signicat-net's Introduction

Signicat .NET SDK

Tests NuGet NuGet

A .NET SDK for simple integration with the Signicat REST APIs, this SDK supports the following APIs:

  • Authentication REST API
  • Digital Evidence Management API
  • Registry Lookups Information API
  • Express Signature API
  • Enterprise Signature API

Supports .NET Standard 2.0+, .NET Core 2.0+ and .NET Framework 4.6.1+.

Installation

Using NuGet is the easiest way to install the SDK.

Package Manager:

PM > Install-Package Signicat.SDK
PM > Install-Package Signicat.SDK.Fluent (optional if you want to use the fluent builder)

.NET Core CLI:

dotnet add package Signicat.SDK
dotnet add package Signicat.SDK.Fluent (optional if you want to use the fluent builder)

Documentation

The SDK have option for both sync and async methods.

Sample Usage

You can set the credentials either in the configuration class as seen below or per service in the constructor.

// Set your credentials
SignicatConfiguration.SetClientCredentials("clientId", "clientSecret");

Authentication

Create session

AuthenticationService _authenticationService = new AuthenticationService();

var createSession = new AuthenticationCreateOptions()
{
    Flow = AuthenticationFlow.Redirect,
    Language = Languages.English,
    AllowedProviders = new List<string>()
    {
        AllowedProviderTypes.NorwegianBankId,
        AllowedProviderTypes.SwedishBankID
    },
    ExternalReference = Guid.NewGuid().ToString("n"),
    CallbackUrls = new CallbackUrls()
    {
        Abort = "https://mytest.com#abort",
        Success = "https://mytest.com#success",
        Error = "https://mytest.com#error",
    },
    RequestedAttributes = new List<string>()
    {
        RequestedAttributes.FirstName,
        RequestedAttributes.LastName,
        RequestedAttributes.NationalIdentifierNumber
    },
    SessionLifetime = 600
};
             
var session = await _authenticationService.CreateSessionAsync(createSession);
Using fluent package
AuthenticationService _authenticationService = new AuthenticationService();

var createSession = AuthenticationCreateOptionsBuilder.Create()
    .WithFlow(AuthenticationFlow.Redirect)
    .WithCallbackUrls(success: "https://myservice.com/success", abort: "https://myservice.com/abort",
        error: "https://myservice.com/error")
    .WithLanguage("no")
    .WithAllowedProviders(AllowedProviderTypes.NorwegianBankId, AllowedProviderTypes.iDIN)
    .WithExternalReference(Guid.NewGuid().ToString())
    .WithThemeId("ab1212")
    .WithSessionLifetime(600)
    .WithRequestedAttributes(RequestedAttributes.FirstName, RequestedAttributes.LastName,
        RequestedAttributes.NationalIdentifierNumber)
    .Build();
                
var session = await _authenticationService.CreateSessionAsync(createSession);

Get session

AuthenticationService _authenticationService = new AuthenticationService();
var session = await _authenticationService.GetSessionAsync("53912d35-eef6-4116-8d7e-8b7c84ffa1f2");

Digital Evidence Management

Create dem record

var digitalEvidenceManagementService = new DigitalEvidenceManagementService();

var newRecord = new DemRecordCreateOptions()
{
    Metadata = new Dictionary<string, object>()
    {
        {"timestamp", DateTime.Now},
        {"hash", "fe8df9859245b024ec1c0f6f825a3b4441fc0dee37dc28e09cc64308ba6714f3"},
    },
    Type = RecordTypes.LOG_IN,
    TimeToLiveInDays = 1,
    CoreData = new Dictionary<string, object>()
    {
        {"name", "Bruce Wayne"},
        {"identityProvider", "WayneEnterpriseCorporateId"},
        {"subject", "9764384103"}
    },
    AuditLevel = AuditLevels.ADVANCED
};
var record = await digitalEvidenceManagementService.CreateDemRecordAsync(newRecord);
Fluent
var digitalEvidenceManagementService = new DigitalEvidenceManagementService();

var options = DemRecordCreateOptionsBuilder.Create()
    .WithType(RecordTypes.LOG_IN)
    .WithAuditLevel(AuditLevels.ADVANCED)
    .WithTimeToLiveInDays(365)
    .WithMetaData(new Dictionary<string, object>()
    {
        {"timestamp", DateTime.Now},
        {"hash", "fe8df9859245b024ec1c0f6f825a3b4441fc0dee37dc28e09cc64308ba6714f3"},
    })
    .WithCoreData(new Dictionary<string, object>()
    {
        {"name", "Bruce Wayne"},
        {"identityProvider", "WayneEnterpriseCorporateId"},
        {"subject", "9764384103"}
    })
    .WithRelations("53912d35-eef6-4116-8d7e-8b7c84ffa1f2")
    .Build();

var response = await digitalEvidenceManagementService.CreateDemRecordAsync(options);

Get record

var digitalEvidenceManagementService = new DigitalEvidenceManagementService();

var retrievedRecord = await _digitalEvidenceManagement.GetRecordAsync("53912d35-eef6-4116-8d7e-8b7c84ffa1f2");

Identity proofing Information Lookup

Run a Organisation Basic lookup

var informationService = new InformationService();

var result = await informationService.GetBasicOrganizationInfoAsync("NO", "989584022");

Express sign

Documentation can be found here: https://developer.signicat.com/docs/electronic-signatures/#electronic-signing. Choose Express sign for examples and documentation specific to the Express Signature API

Create document

var expressSignatureService = new ExpressSignatureService();
var signOptions = new DocumentCreateOptions()
{
    Title = "SDK Example",
    Signers = new List<SignerOptions>()
    {
        new ()
        {
            ExternalSignerId = "Signer1",
            RedirectSettings = new RedirectSettings()
            {
                RedirectMode = RedirectMode.DonotRedirect
            },
            SignatureType = new SignatureType()
            {
                Mechanism = SignatureMechanism.Handwritten
            }
        }
    },
    ExternalId = "pakdfmoqumr-1234",
    ContactDetails = new ContactDetails()
    {
        Email = "[email protected]"
    },
    DataToSign = new DataToSign()
    {
        FileName = "sample.txt",
        Base64Content = "VGhpcyB0ZXh0IGNhbiBzYWZlbHkgYmUgc2lnbmVk",
        Title = "Document title",
        Description = "Document description",
        ConvertToPdf = false
    }
};
var document = await expressSignatureService.CreateDocumentAsync(signOptions);

Get document

var document = await _expressSignatureService.GetDocumentAsync(documentId);

Support

signicat-net's People

Contributors

runes83 avatar vpolland avatar slettan avatar abbas-signicat avatar io7-christian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.