Coder Social home page Coder Social logo

admin's Introduction

Manage your Kobble project and users from your server with Kobble Admin SDK

License Status Deno Node Supabase

Getting started

Initialize a Kobble instance from a secret generated from your Kobble dashboard.

import { Kobble } from '@kobbleio/admin'

const main = async () => {
    const kobble = new Kobble('YOUR_SECRET');
    const whoami = await kobble.whoami();

    // To verify your setup
    console.log(whoami);
}

main();

Verify User Tokens

Verify ID Token

You can verify ID tokens obtained using Kobble frontend SDKs as follows:

import { Kobble } from '@kobbleio/admin'

const main = async () => {
    const kobble = new Kobble('YOUR_SECRET');
    const result = await kobble.auth.verifyIdToken('ID_TOKEN');
    
    console.log(result)
    // Output:
    // {
    //     userId: 'clu9ob5480001mdhwk9qt00hv',
    //     user: {
    //         id: 'clu9ob5480001mdhwk9qt00hv',
    //         email: '[email protected]',
    //         name: null,
    //         pictureUrl: null,
    //         isVerified: true,
    //         stripeId: null,
    //         updatedAt: 2024-03-27T10:39:02.000Z,
    //         createdAt: 2024-03-27T10:39:02.000Z
    //     },
    //     claims: { ... }
    // }
}

Verify Access Token

You can verify access tokens obtained using Kobble frontend SDKs as follows:

import { Kobble } from '@kobbleio/admin'

const main = async () => {
    const kobble = new Kobble('YOUR_SECRET');
    
    const result = await kobble.auth.verifyAccessToken('ACCESS_TOKEN');
    
    console.log(result)
    // Output:
    // {
    //     projectId: 'cltxiphfv000129anb0kuagow',
    //     userId: 'clu9ob5480001mdhwk9qt00hv',
    //     claims: {
    //         sub: 'clu9ob5480001mdhwk9qt00hv',
    //         project_id: 'cltxiphfv000129anb0kuagow',
    //         iat: 1713183109,
    //         exp: 1713186709689,
    //         iss: 'https://kobble.io',
    //         aud: 'clu9ntcvr0000o9yfz87ybo4a'
    //     }
    // }
}

The main difference between the two tokens is that the ID token contains user information, while the access token contains project and User ID only.

Documentation

Exported functions are extensively documented, and more documentation can be found on our official docs.


What is Kobble?

Kobble Logo

Kobble is the one-stop solution for monetizing modern SaaS and APIs. It allows to add authentication, analytics and payment to any app in under 10 minutes.

admin's People

Contributors

kevinpiac avatar

Watchers

 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.