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 🙏

© 2026 – Pkg Stats / Ryan Hefner

xepeng-oauth-js

v1.1.2

Published

Xepeng OAuth JS SDK for React, Vue and more

Downloads

58

Readme

Xepeng JS SDK 🚀

Version License

The Xepeng JS SDK is a powerful, type-safe library for implementing OAuth 2.0 with PKCE and Payment Integration in your applications. Optimized for React, Vue, and Node.js.

✨ Key Features

  • 🔒 OAuth 2.0 + PKCE: Secure authentication for SPAs (React, Vue, Svelte) and mobile apps.
  • 🧬 Smart Callback: handleCallback() automatically detects context and exchanges codes.
  • 🔄 Auto Token Refresh: Background token renewal for seamless user sessions.
  • 💳 Payment Integration: Manage orders and payment links with automatic HMAC-SHA256 signing.
  • 🛡️ Isomorphic Design: Separate modules for Browser (OAuth) and Node.js (Integration) to ensure maximum security and minimum bundle size.
  • ⚛️ Framework First: Native hooks for React and composables for Vue 3.

🚀 Installation

npm install xepeng-oauth-js
# or
yarn add xepeng-oauth-js
# or
bun add xepeng-oauth-js

🔐 OAuth 2.0 (Browser / Frontend)

Gunakan modul ini untuk login pengguna di aplikasi frontend.

1. Inisialisasi Client

import { OAuthClient } from "xepeng-oauth-js";

const oauth = new OAuthClient({
  clientId: "YOUR_CLIENT_ID",
  baseUrl: "https://staging-app.xepeng.com", // Opsional
  redirectUri: "http://localhost:5173/auth/callback",
  storage: "localStorage", // 'localStorage', 'sessionStorage', atau 'memory'
});

2. Alur Login & Callback

// Langkah 1: Redirect ke halaman login
const login = async () => {
  const url = await oauth.getAuthorizationUrl();
  window.location.href = url;
};

// Langkah 2: Tangani callback (di halaman redirect)
const handleAuth = async () => {
  try {
    const response = await oauth.handleCallback();
    console.log("Login Berhasil!", response);
  } catch (error) {
    console.error("Gagal Login:", error.message);
  }
};

💳 Payment Integration (Server-Side / Node.js)

Gunakan modul ini di backend atau SvelteKit/Next.js server-side. Modul ini terpisah untuk menjaga keamanan clientSecret.

1. Inisialisasi Integration Client

import { XepengIntegrationClient } from "xepeng-oauth-js/integration";

const client = new XepengIntegrationClient({
  clientId: "YOUR_CLIENT_ID",
  clientSecret: "YOUR_CLIENT_SECRET", // WAJIB di server-side
  isProduction: false,
});

2. Manajemen Order & Pembayaran

// Membuat Order
const orderResponse = await client.orders().create([
  {
    amount: 50000,
    product_name: "Kemeja Flanel",
    product_description: "Size L, Merah",
  }
]);

// Membuat Link Pembayaran
const payment = await client.paymentLinks().generate(orderResponse.data.uid, {
  success_url: "https://toko.com/success",
  callback_url: "https://api.toko.com/v1/callback"
});

console.log("URL Pembayaran:", payment.data.payment_url);

⚛️ Framework Support

React

import { useOAuth } from "xepeng-oauth-js/react";

function App() {
  const { login, user, isAuthenticated } = useOAuth(config);
  return <button onClick={login}>{isAuthenticated ? user.name : "Login"}</button>;
}

Vue 3

<script setup>
import { useOAuth } from "xepeng-oauth-js/vue";
const { login, user, isAuthenticated } = useOAuth(config);
</script>

<template>
  <button @click="login">{{ isAuthenticated ? user.name : 'Connect Xepeng' }}</button>
</template>

🛡️ Keamanan & Bundle Size

Browser vs Node.js

SDK ini menggunakan sistem Conditional Exports. Fitur integrasi (/integration) menggunakan modul Node.js crypto untuk tanda tangan HMAC. Dengan memisahkan impor, aplikasi frontend Anda tidak akan membengkak atau mengalami error karena dependensi Node.js.

| Modul | Penggunaan | Lingkungan | | :--- | :--- | :--- | | xepeng-oauth-js | OAuth & SSO | Browser (Vite, Webpack, dll) | | xepeng-oauth-js/integration | Payment & Orders | Node.js / Server-side | | xepeng-oauth-js/react | React Hook | Browser | | xepeng-oauth-js/vue | Vue Composable | Browser |


📄 License

MIT © Xepeng