Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@atproto/did

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atproto/did - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1-rc.0

dist/atproto.d.ts

1

dist/did.d.ts

@@ -55,3 +55,4 @@ import { z } from 'zod';

export declare function isDid(input: unknown): input is Did;
export declare function asDid(input: unknown): Did;
export declare const didSchema: z.ZodEffects<z.ZodString, `did:${string}:${string}`, string>;
//# sourceMappingURL=did.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.didSchema = exports.isDid = exports.checkDid = exports.checkDidMsid = exports.extractDidMethod = exports.checkDidMethod = exports.DID_PREFIX = void 0;
exports.didSchema = exports.asDid = exports.isDid = exports.checkDid = exports.checkDidMsid = exports.extractDidMethod = exports.checkDidMethod = exports.DID_PREFIX = void 0;
const zod_1 = require("zod");

@@ -129,2 +129,3 @@ const did_error_js_1 = require("./did-error.js");

}
// Unexpected TypeError (should never happen)
throw err;

@@ -134,2 +135,7 @@ }

exports.isDid = isDid;
function asDid(input) {
checkDid(input);
return input;
}
exports.asDid = asDid;
exports.didSchema = zod_1.z

@@ -136,0 +142,0 @@ .string()

@@ -0,1 +1,2 @@

export * from './atproto.js';
export * from './did-document.js';

@@ -2,0 +3,0 @@ export * from './did-error.js';

@@ -17,2 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./atproto.js"), exports);
__exportStar(require("./did-document.js"), exports);

@@ -19,0 +20,0 @@ __exportStar(require("./did-error.js"), exports);

3

dist/methods/plc.d.ts

@@ -5,3 +5,4 @@ import { Did } from '../did.js';

export declare function isDidPlc(input: unknown): input is Did<'plc'>;
export declare function checkDidPlc(input: string): asserts input is Did<'plc'>;
export declare function asDidPlc(input: unknown): Did<'plc'>;
export declare function checkDidPlc(input: unknown): asserts input is Did<'plc'>;
//# sourceMappingURL=plc.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkDidPlc = exports.isDidPlc = exports.DID_PLC_PREFIX = void 0;
exports.checkDidPlc = exports.asDidPlc = exports.isDidPlc = exports.DID_PLC_PREFIX = void 0;
const did_error_js_1 = require("../did-error.js");

@@ -10,2 +10,3 @@ const DID_PLC_PREFIX = `did:plc:`;

function isDidPlc(input) {
// Optimization: make cheap checks first
if (typeof input !== 'string')

@@ -22,3 +23,11 @@ return false;

exports.isDidPlc = isDidPlc;
function asDidPlc(input) {
checkDidPlc(input);
return input;
}
exports.asDidPlc = asDidPlc;
function checkDidPlc(input) {
if (typeof input !== 'string') {
throw new did_error_js_1.InvalidDidError(typeof input, `DID must be a string`);
}
if (input.length !== DID_PLC_LENGTH) {

@@ -25,0 +34,0 @@ throw new did_error_js_1.InvalidDidError(input, `did:plc must be ${DID_PLC_LENGTH} characters long`);

@@ -5,13 +5,8 @@ import { Did } from '../did.js';

* This function checks if the input is a valid Web DID, as per DID spec.
* ATPROTO adds additional constraints to allowed DID values for the `did:web`
* method. Use {@link isAtprotoDidWeb} if that's what you need.
*/
export declare function isDidWeb(input: unknown): input is Did<'web'>;
/**
* @see {@link https://atproto.com/specs/did#blessed-did-methods}
*/
export declare function isAtprotoDidWeb(input: unknown): input is Did<'web'>;
export declare function checkDidWeb(input: string): asserts input is Did<'web'>;
export declare function asDidWeb(input: unknown): Did<'web'>;
export declare function checkDidWeb(input: unknown): asserts input is Did<'web'>;
export declare function didWebToUrl(did: string): URL;
export declare function urlToDidWeb(url: URL): Did<'web'>;
//# sourceMappingURL=web.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.urlToDidWeb = exports.didWebToUrl = exports.checkDidWeb = exports.isAtprotoDidWeb = exports.isDidWeb = exports.DID_WEB_PREFIX = void 0;
exports.urlToDidWeb = exports.didWebToUrl = exports.checkDidWeb = exports.asDidWeb = exports.isDidWeb = exports.DID_WEB_PREFIX = void 0;
const did_error_js_1 = require("../did-error.js");

@@ -9,10 +9,9 @@ const did_js_1 = require("../did.js");

* This function checks if the input is a valid Web DID, as per DID spec.
* ATPROTO adds additional constraints to allowed DID values for the `did:web`
* method. Use {@link isAtprotoDidWeb} if that's what you need.
*/
function isDidWeb(input) {
// Optimization: make cheap checks first
if (typeof input !== 'string')
return false;
try {
didWebToUrl(input);
checkDidWeb(input);
return true;

@@ -25,25 +24,13 @@ }

exports.isDidWeb = isDidWeb;
/**
* @see {@link https://atproto.com/specs/did#blessed-did-methods}
*/
function isAtprotoDidWeb(input) {
// Optimization: make cheap checks first
function asDidWeb(input) {
checkDidWeb(input);
return input;
}
exports.asDidWeb = asDidWeb;
function checkDidWeb(input) {
if (typeof input !== 'string') {
return false;
throw new did_error_js_1.InvalidDidError(typeof input, `DID must be a string`);
}
// Path are not allowed
if (input.includes(':', exports.DID_WEB_PREFIX.length)) {
return false;
}
// Port numbers are not allowed, except for localhost
if (input.includes('%3A', exports.DID_WEB_PREFIX.length) &&
!input.startsWith('did:web:localhost%3A')) {
return false;
}
return isDidWeb(input);
void didWebToUrl(input);
}
exports.isAtprotoDidWeb = isAtprotoDidWeb;
function checkDidWeb(input) {
didWebToUrl(input);
}
exports.checkDidWeb = checkDidWeb;

@@ -50,0 +37,0 @@ function didWebToUrl(did) {

{
"name": "@atproto/did",
"version": "0.1.0",
"version": "0.1.1-rc.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "DID resolution and verification library",

@@ -241,2 +241,4 @@ import { z } from 'zod'

}
// Unexpected TypeError (should never happen)
throw err

@@ -246,2 +248,7 @@ }

export function asDid(input: unknown): Did {
checkDid(input)
return input
}
export const didSchema = z

@@ -248,0 +255,0 @@ .string()

@@ -0,1 +1,2 @@

export * from './atproto.js'
export * from './did-document.js'

@@ -2,0 +3,0 @@ export * from './did-error.js'

@@ -11,3 +11,5 @@ import { InvalidDidError } from '../did-error.js'

export function isDidPlc(input: unknown): input is Did<'plc'> {
// Optimization: make cheap checks first
if (typeof input !== 'string') return false
try {

@@ -21,3 +23,12 @@ checkDidPlc(input)

export function checkDidPlc(input: string): asserts input is Did<'plc'> {
export function asDidPlc(input: unknown): Did<'plc'> {
checkDidPlc(input)
return input
}
export function checkDidPlc(input: unknown): asserts input is Did<'plc'> {
if (typeof input !== 'string') {
throw new InvalidDidError(typeof input, `DID must be a string`)
}
if (input.length !== DID_PLC_LENGTH) {

@@ -24,0 +35,0 @@ throw new InvalidDidError(

import { InvalidDidError } from '../did-error.js'
import { Did, checkDidMsid } from '../did.js'
export const DID_WEB_PREFIX = `did:web:`
export const DID_WEB_PREFIX = `did:web:` satisfies Did<'web'>
/**
* This function checks if the input is a valid Web DID, as per DID spec.
* ATPROTO adds additional constraints to allowed DID values for the `did:web`
* method. Use {@link isAtprotoDidWeb} if that's what you need.
*/
export function isDidWeb(input: unknown): input is Did<'web'> {
// Optimization: make cheap checks first
if (typeof input !== 'string') return false
try {
didWebToUrl(input)
checkDidWeb(input)
return true

@@ -21,31 +21,15 @@ } catch {

/**
* @see {@link https://atproto.com/specs/did#blessed-did-methods}
*/
export function isAtprotoDidWeb(input: unknown): input is Did<'web'> {
// Optimization: make cheap checks first
export function asDidWeb(input: unknown): Did<'web'> {
checkDidWeb(input)
return input
}
export function checkDidWeb(input: unknown): asserts input is Did<'web'> {
if (typeof input !== 'string') {
return false
throw new InvalidDidError(typeof input, `DID must be a string`)
}
// Path are not allowed
if (input.includes(':', DID_WEB_PREFIX.length)) {
return false
}
// Port numbers are not allowed, except for localhost
if (
input.includes('%3A', DID_WEB_PREFIX.length) &&
!input.startsWith('did:web:localhost%3A')
) {
return false
}
return isDidWeb(input)
void didWebToUrl(input)
}
export function checkDidWeb(input: string): asserts input is Did<'web'> {
didWebToUrl(input)
}
export function didWebToUrl(did: string): URL {

@@ -52,0 +36,0 @@ if (!did.startsWith(DID_WEB_PREFIX)) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc