Skip to content

cometh-hq/hosted-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect Hosted SDK

Connect Hosted SDK allows developers to interact with Cometh hosted Wallet, combining web2 authentication through an OIDC provider and web3 wallet using Connect.

TODO: put more details about Cometh hosted Wallet (OIDC + Connect)

Register on Cometh OIDC

Cometh OIDC is the authentication provider for Cometh. In order to use the Cometh hosted Wallet, you need to register your application on Cometh OIDC.

Steps:

  1. Create an account on Cometh. You may have to request access to the platform for your company/project.
  2. Create a new project
  3. Activate OIDC in the project settings
or set OIDC config with this API call

TODO: delete this section once dashboard is ready

  1. Request OIDC access (Kong) for your project
  2. Call the following API to create your OIDC client
curl --location 'https://oidc-hosted-connect.develop.core.cometh.tech' \
--header 'Content-Type: application/json' \
--header 'apisecret: xxx' \ # your api key
--data '{
    "name": "xxx", # your application name
    "redirect_uris": [
        "xxx" # your redirect uri 
    ],
    "grant_types": [
        "authorization_code"
    ],
    "token_endpoint_auth_method": "none",
    "response_types": [
        "code"
    ],
    "allowed_oauth2_providers": ["google", "guest"]
    "scope": "openid wallet email profile"
}'

Once you have activated your client account on ComethOIDC, you can start an OIDC flow in your application.

Authenticate with Cometh OIDC

Basic flow

Our SDK provides a simple way to authenticate with Cometh OIDC using IFrames.

Detailed SDK documentation can be found here.

Manual & Third-party flow

Cometh OIDC follow the OIDC standard and so can be implemented in any application that supports OIDC authentication. The details of this implementation are out of the scope of this SDK and will depend on your stack.

The Identity of the user will ultimately contain:

interface ComethIdentity {
    sub: string // user id
    wallet: string // wallet address
    nickname?: string
    email?: string
}
Here is an example on how to use Cometh OIDC with a NextJS application using NextAuth
import type { OAuthConfig, OAuthUserConfig } from "next-auth/providers/"

interface ComethProfile {
    id: string
    wallet: string
}

export default function Cometh<P extends ComethProfile>(
    options: OAuthUserConfig<P>
): OAuthConfig<P> {
    return {
        id: "cometh",
        name: "Cometh",
        type: "oidc",
        authorization: {
            params: { scope: "openid email profile wallet" },
        },
        checks: ["pkce"],
        issuer: 'https://oidc-hosted-connect.cometh.io',
        profile(profile, tokens) {
            return {
                id: profile.sub,
                wallet: profile.wallet
            };
        },
        ...options,
    };
}

Hosted Cometh Smart-Wallet

Detailed SDK documentation can be found here.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published