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

checkpac

v1.2.0

Published

Validate PAC/STAC codes, with rich metadata included

Downloads

1

Readme

CheckPAC

A simple array of validation tools for PAC and STAC codes, as defined by the Mobile Number Portability Operator Steering Group. These one-time use codes are provided by mobile network operators in the UK, as required by Ofcom, to "port" a mobile number to another network, in effect allowing a customer to use their old phone number with a different network. This tool also provides metadata relating to the provided code, built from a database by hand (from searching on google).

This package aims to follow a structure similar to libphonenumber-js, providing the following methods:

  • Validate a complete PAC/STAC number, optionally with metadata, optionally only PAC or STAC
  • Check-as-you-type (Work in progress)
  • Validate SP (service provider) identifiers

This package will not check whether the code is active and usable; merely that it is in the correct format. You still need to validate against Syniverse/the Central Switching System. This library is best for front-end validation.

PAC/STAC TL;DR

PACs (Porting Authorisation Codes) and STACs (Service Termination Authorisation Codes, also known as N-PACs) are tokens SP (Mobile Networks a.k.a Service Providers) customers can request when leaving their provider in order to easily cancel their contract and (optionally) "port" their number. The specifics of how they're generated and managed are discussed in the manual published by the steering group that created the system. The whole system is managed by Ofcom, the UK's regulator and watchdog for communications.

The codes comprise of two components: the SP identifier, which is three letters long, and the unique code, which is six digits long. PAC codes are in that order STAC codes are the opposite. The customer obtains the code by texting the 65075/75075 service or by requesting a code through customer services. The code is issued instantly and is valid for 30 calendar days.

This tool validates the SP identifier against a list collected from across the internet, and validates the length of the unique code.

Installation

yarn add checkpac

Instructions for using client-side with unpkg etc coming soon...

Development notes

This project is a work in progress

  • Run yarn build before commiting changes, and yarn schema if you've made a difference to any types in src/types.ts.

Contributing

Please read CONTRIBUTING.md :)

Example usage

React

import React, { useCallback, useState } from "react";
import { validateAuthCode } from "checkpac";

const ExampleForm = props => {
  const [authForm, updateAuthForm] = useState({});

  const onSubmit = useCallback(() => {
    const { success } = validateAuthCode(authForm.code);
    if (success) {
      // dispatch some api action
    } else {
      // show error messages in form
    }
  }, []);

  return (
    <div>
      <form name="authForm" onSubmit={e => e.preventDefault()}>
        <label htmlFor="code">Enter your PAC/STAC code</label>
        <input name="code" placeholder="AAA123456" onChange={e => updateAuthForm({ ...authForm, code: e.target.value })} />
        <input type="submit" value="Next" onPress={onSubmit}>
      </form>
    </div>
  );
};

export default ExampleForm;

Formik / Yup React example

to-do

Angular example

to-do

Vanilla JS browser example

to-do