npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ramper-v2/telegram-sdk

v1.0.9

Published

Ramper Social Login

Downloads

688

Readme

Ramper Telegram

The ways of adding RamperTelegram to a project

import RamperTelegram from 'ramper-telegram';
const sdkConfig = {
    // gameId provided by Ramper, request before using the SDK (optional)
    gameId: 'sdk_sample',
    partner: 'coin98',
    // partner app id provided by Ramper, request before using the SDK (required)
    appId: 'missing_app_id',
    // source provided by Ramper, request before using the SDK (optional)
    source: 'source_sample',
    // currently we support 2 blockchains: 'orange' and 'tomo', if not provided, default is 'tomo' (optional)
    chain: 'orange' | 'tomo',
    // callback functions for handling sign in success, sign in fail and sign message
    onSignInSucess: (uProfile) => {
        // handle user profile after sign in success
        console.log('sign-in-success', uProfile);
    },
    onSignMessage: (msg) => {
        // handle message after sign in success
        console.log('sign-message-success', msg);
    },
    onSignInFail: (ev) => {
        // handle sign in fail
        console.error('sign-in-fail', ev);
    }
}

// Initialize RamperTelegram
RamperTelegram.initializeAsync(sdkConfig)
    .then(() => {
        console.log('init ramper success')
    })
    .catch((reason => {
        console.error('');
    }))

FUNCTIONS

getSDKVersion

Description

The string representation of this SDK version.

getSDKVersion(): string

Returns

string Returns string The SDK version.

Example

var sdkVersion = RamperTelegram.getSDKVersion(); // '1.0'

hideIframe

Description

Hide iframe

hideIframe(): void

Returns

void

Example

RamperTelegram.hideIframe();

initializeAsync

Description

Initializes the SDK library. This should be called before any other SDK functions. Login request be fired on this.

initializeAsync(config): Promise<any>

Parameters

config: Object • Properties ts gameId: string; partner: string; onSignInSucess: (userProfile: UserProfile) => void; onSignMessage: (data: Object) => void; onSignInFail: (data: Object) => void;

Returns

Promise<void>

Example

RamperTelegram.initializeAsync({
    gameId: 'sdk_sample',
    partner: 'coin98',
    appId: 'missing_app_id',
    onSignInFail: (ev) => {
        console.error('sign in fail');
    },
    onSignInSucess: (uProfile) => {
        console.log('sign-in-success', uProfile);
    },
    onSignMessage: (msg) => {
        console.log('sign-message-success', msg);
    }
})

showIframe

Description

Open iframe with target url

showIframe(url, afterLoadUrlCallback): void

Parameters

url: string set a callback to be fired on web loaded • afterLoadUrlCallback: any

Returns

void

Example

RamperTelegram.showIframe(
    'example.com',
    ()=>{
        console.log('load url success')
    }
)

signMessage

Description

Sign a string data.

signMessage(msg): void

Parameters

msg: string

Returns

void

Example

RamperTelegram.signMessage('Hello World');

signOut

Description

Sign out the user.

signOut(callback): void

Parameters

Set a callback to be fired when a logout is triggered. • callback: Function

RamperTelegram.signOut(function() {
  console.log('logout event was triggered!');
})

Returns

void

Other platforms support

NuxtJs Example

<script>
  export default {
    name: 'IndexPage',
    data() {
      return {
        RamperInstant: null, // Placeholder for SDK
        isSDKLoaded: false,  // Flag to track if SDK is loaded
        address : '',
        UID: '',
        email: '',
        profileName: '',
        tgUserId: '',
        loading: false,
        signMessage: 'Welcome to Zamper Telegram SDK',
        signature: '',
        verifyAddress: '',
      };
    },
    mounted() {
      if (process.client) {
        // Ensure the SDK is loaded on client-side only
        console.log("Client detected, loading SDK...");
        import('@ramper-v2/telegram-sdk')
          .then(module => {

            this.RamperInstant = module; // Assign the SDK
            this.isSDKLoaded = true; // Mark SDK as loaded
            console.log("SDK loaded successfully", module);
          })
          .catch(error => {
            console.error('Failed to load SDK:', error);
          });
      }
    },
    methods: {
      initializeSDK() {
        if (this.RamperInstant) {
          this.loading = true
          const sdkConfig = {
            partner: '',
            gameId: '',
            appId: "",
            source: "",
            onSignInSucess: (uProfile) => {
              console.debug("🚀 ~ initializeSDK ~ uProfile:", uProfile);
              const {UID, email, profileName, tgUser, wallets} = uProfile.data;
              this.UID = UID.substring(0, 10);
              this.email = email;
              this.profileName = profileName;
              this.address = wallets.tomo.publicKey;
              this.tgUserId = tgUser.userId;
              this.loading = false
            },
            onSignMessage: (data) => {
              this.signature = data;
              this.loading = false
            },
            onSignInFail: (ev) => {
              this.loading = false
            },
          };
          this.RamperInstant.initializeAsync(
            sdkConfig,
            'preprod'
          )
        } else {
          console.log('SDK not loaded yet');
        }
      },
      onSignMessageButton() {
        if (this.RamperInstant) {
          const signature = this.RamperInstant.signMessage(this.signMessage, '');
        }
      }
    }
  }
</script>