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

@atproto-labs/identity-resolver

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atproto-labs/identity-resolver - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

tsconfig.build.json

15

CHANGELOG.md
# @atproto-labs/identity-resolver
## 0.0.1
## 0.1.0
### Minor Changes
- [#2482](https://github.com/bluesky-social/atproto/pull/2482) [`a8d6c1123`](https://github.com/bluesky-social/atproto/commit/a8d6c112359f5c4c0cfbe2df63443ed275f2a646) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add OAuth provider capability & support for DPoP signed tokens
### Patch Changes
- [`e134c79a0`](https://github.com/bluesky-social/atproto/commit/e134c79a0ffb000b2cb36437815673fa6bda664b) Thanks [@devinivy](https://github.com/devinivy)! - Initial publish of experimental oauth packages to @atproto-labs
- Updated dependencies [[`e134c79a0`](https://github.com/bluesky-social/atproto/commit/e134c79a0ffb000b2cb36437815673fa6bda664b)]:
- @atproto-labs/handle-resolver@0.0.1
- @atproto-labs/fetch@0.0.1
- @atproto-labs/did@0.0.1
- Updated dependencies [[`a8d6c1123`](https://github.com/bluesky-social/atproto/commit/a8d6c112359f5c4c0cfbe2df63443ed275f2a646)]:
- @atproto-labs/handle-resolver@0.1.0
- @atproto-labs/did-resolver@0.1.0

@@ -1,13 +0,14 @@

import { DidResolver } from '@atproto-labs/did';
import { HandleResolver, ResolvedHandle } from '@atproto-labs/handle-resolver';
import { ResolveOptions as DidResolveOptions, DidResolver } from '@atproto-labs/did-resolver';
import { ResolveOptions as HandleResolveOptions, HandleResolver, ResolvedHandle } from '@atproto-labs/handle-resolver';
export type ResolvedIdentity = {
did: NonNullable<ResolvedHandle>;
url: URL;
pds: URL;
};
export type ResolveOptions = DidResolveOptions & HandleResolveOptions;
export declare class IdentityResolver {
readonly didResolver: DidResolver<'plc' | 'web'>;
readonly handleResolver: HandleResolver;
readonly didResolver: DidResolver<'plc' | 'web'>;
constructor(handleResolver: HandleResolver, didResolver: DidResolver<'plc' | 'web'>);
resolve(input: string, serviceType?: string): Promise<ResolvedIdentity>;
constructor(didResolver: DidResolver<'plc' | 'web'>, handleResolver: HandleResolver);
resolve(input: string, options?: ResolveOptions): Promise<ResolvedIdentity>;
}
//# sourceMappingURL=identity-resolver.d.ts.map

@@ -7,29 +7,39 @@ "use strict";

class IdentityResolver {
constructor(handleResolver, didResolver) {
Object.defineProperty(this, "handleResolver", {
constructor(didResolver, handleResolver) {
Object.defineProperty(this, "didResolver", {
enumerable: true,
configurable: true,
writable: true,
value: handleResolver
value: didResolver
});
Object.defineProperty(this, "didResolver", {
Object.defineProperty(this, "handleResolver", {
enumerable: true,
configurable: true,
writable: true,
value: didResolver
value: handleResolver
});
}
async resolve(input, serviceType = 'AtprotoPersonalDataServer') {
async resolve(input, options) {
const did = (0, handle_resolver_1.isResolvedHandle)(input)
? input // Already a did
: await this.handleResolver.resolve((0, syntax_1.normalizeAndEnsureValidHandle)(input));
if (!did)
throw new Error(`Handle ${input} does not resolve to a DID`);
const url = await this.didResolver.resolveServiceEndpoint(did, {
type: serviceType,
});
return { did, url };
: await this.handleResolver.resolve((0, syntax_1.normalizeAndEnsureValidHandle)(input), options);
options?.signal?.throwIfAborted();
if (!did) {
throw new TypeError(`Handle "${input}" does not resolve to a DID`);
}
const document = await this.didResolver.resolve(did, options);
const service = document.service?.find((isAtprotoPersonalDataServerService), document);
if (!service) {
throw new TypeError(`No valid "AtprotoPersonalDataServer" service found in "${did}" DID document`);
}
const pds = new URL(service.serviceEndpoint);
return { did, pds };
}
}
exports.IdentityResolver = IdentityResolver;
function isAtprotoPersonalDataServerService(s) {
return (typeof s.serviceEndpoint === 'string' &&
s.type === 'AtprotoPersonalDataServer' &&
(s.id === '#atproto_pds' || s.id === `${this.id}#atproto_pds`));
}
//# sourceMappingURL=identity-resolver.js.map
export * from './identity-resolver.js';
export * from './universal-identity-resolver.js';
//# sourceMappingURL=index.d.ts.map

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

__exportStar(require("./identity-resolver.js"), exports);
__exportStar(require("./universal-identity-resolver.js"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@atproto-labs/identity-resolver",
"version": "0.0.1",
"version": "0.1.0",
"license": "MIT",

@@ -16,3 +16,3 @@ "description": "A library resolving ATPROTO identities",

"url": "https://github.com/bluesky-social/atproto",
"directory": "packages/identity-resolver"
"directory": "packages/internal/identity-resolver"
},

@@ -29,5 +29,4 @@ "type": "commonjs",

"dependencies": {
"@atproto-labs/did": "0.0.1",
"@atproto-labs/fetch": "0.0.1",
"@atproto-labs/handle-resolver": "0.0.1",
"@atproto-labs/did-resolver": "0.1.0",
"@atproto-labs/handle-resolver": "0.1.0",
"@atproto/syntax": "0.3.0"

@@ -34,0 +33,0 @@ },

@@ -1,3 +0,10 @@

import { DidResolver } from '@atproto-labs/did'
import {
Did,
DidDocument,
ResolveOptions as DidResolveOptions,
DidResolver,
DidService,
} from '@atproto-labs/did-resolver'
import {
ResolveOptions as HandleResolveOptions,
HandleResolver,

@@ -11,9 +18,11 @@ ResolvedHandle,

did: NonNullable<ResolvedHandle>
url: URL
pds: URL
}
export type ResolveOptions = DidResolveOptions & HandleResolveOptions
export class IdentityResolver {
constructor(
readonly didResolver: DidResolver<'plc' | 'web'>,
readonly handleResolver: HandleResolver,
readonly didResolver: DidResolver<'plc' | 'web'>,
) {}

@@ -23,15 +32,49 @@

input: string,
serviceType = 'AtprotoPersonalDataServer',
options?: ResolveOptions,
): Promise<ResolvedIdentity> {
const did = isResolvedHandle(input)
? input // Already a did
: await this.handleResolver.resolve(normalizeAndEnsureValidHandle(input))
if (!did) throw new Error(`Handle ${input} does not resolve to a DID`)
: await this.handleResolver.resolve(
normalizeAndEnsureValidHandle(input),
options,
)
const url = await this.didResolver.resolveServiceEndpoint(did, {
type: serviceType,
})
options?.signal?.throwIfAborted()
return { did, url }
if (!did) {
throw new TypeError(`Handle "${input}" does not resolve to a DID`)
}
const document = await this.didResolver.resolve(did, options)
const service = document.service?.find(
isAtprotoPersonalDataServerService<'plc' | 'web'>,
document,
)
if (!service) {
throw new TypeError(
`No valid "AtprotoPersonalDataServer" service found in "${did}" DID document`,
)
}
const pds = new URL(service.serviceEndpoint)
return { did, pds }
}
}
function isAtprotoPersonalDataServerService<M extends string>(
this: DidDocument<M>,
s: DidService,
): s is {
id: '#atproto_pds' | `${Did<M>}#atproto_pds`
type: 'AtprotoPersonalDataServer'
serviceEndpoint: string
} {
return (
typeof s.serviceEndpoint === 'string' &&
s.type === 'AtprotoPersonalDataServer' &&
(s.id === '#atproto_pds' || s.id === `${this.id}#atproto_pds`)
)
}
export * from './identity-resolver.js'
export * from './universal-identity-resolver.js'
{
"extends": "../../tsconfig/isomorphic.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"]
"include": [],
"references": [{ "path": "./tsconfig.build.json" }]
}

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