Skip to content

Commit

Permalink
fix(deps): use Resolvable type from did-resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Mar 26, 2021
1 parent 3ce38e0 commit 4641e56
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@stablelib/sha256": "^1.0.0",
"@stablelib/x25519": "^1.0.0",
"@stablelib/xchacha20poly1305": "^1.0.0",
"did-resolver": "^3.0.2",
"did-resolver": "^3.1.0",
"elliptic": "^6.5.4",
"js-sha3": "^0.8.0",
"uint8arrays": "^2.1.3"
Expand Down
8 changes: 3 additions & 5 deletions src/JWT.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import VerifierAlgorithm from './VerifierAlgorithm'
import SignerAlg from './SignerAlgorithm'
import { encodeBase64url, decodeBase64url, EcdsaSignature } from './util'
import type { Resolver, VerificationMethod, DIDResolutionResult, DIDDocument } from 'did-resolver'
import type { Resolvable, VerificationMethod, DIDResolutionResult, DIDDocument } from 'did-resolver'

export type Signer = (data: string | Uint8Array) => Promise<EcdsaSignature | string>
export type SignerAlgorithm = (payload: string, signer: Signer) => Promise<string>
Expand All @@ -16,14 +16,12 @@ export interface JWTOptions {
expiresIn?: number
}

export type Public<T> = { [P in keyof T]: T[P] }

export interface JWTVerifyOptions {
/** @deprecated Please use `proofPurpose: 'authentication' instead` */
auth?: boolean
audience?: string
callbackUrl?: string
resolver?: Public<Resolver>
resolver?: Resolvable
skewTime?: number
/** See https://www.w3.org/TR/did-spec-registries/#verification-relationships */
proofPurpose?: 'authentication' | 'assertionMethod' | 'capabilityDelegation' | 'capabilityInvocation' | string
Expand Down Expand Up @@ -350,7 +348,7 @@ export async function verifyJWT(
* @return {Promise<DIDAuthenticator>} a promise which resolves with a response object containing an array of authenticators or if non exist rejects with an error
*/
export async function resolveAuthenticator(
resolver: Public<Resolver>,
resolver: Resolvable,
alg: string,
issuer: string,
proofPurpose?: string
Expand Down
5 changes: 2 additions & 3 deletions src/xc20pEncryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { randomBytes } from '@stablelib/random'
import { concatKDF } from './Digest'
import { bytesToBase64url, base58ToBytes, encodeBase64url, toSealed, base64ToBytes } from './util'
import { Recipient, EncryptionResult, Encrypter, Decrypter } from './JWE'
import type { VerificationMethod, Resolver } from 'did-resolver'
import { Public } from './JWT'
import type { VerificationMethod, Resolvable } from 'did-resolver'

function xc20pEncrypter(key: Uint8Array): (cleartext: Uint8Array, aad?: Uint8Array) => EncryptionResult {
const cipher = new XChaCha20Poly1305(key)
Expand Down Expand Up @@ -79,7 +78,7 @@ export function x25519Encrypter(publicKey: Uint8Array, kid?: string): Encrypter
return { alg, enc: 'XC20P', encrypt, encryptCek }
}

export async function resolveX25519Encrypters(dids: string[], resolver: Public<Resolver>): Promise<Encrypter[]> {
export async function resolveX25519Encrypters(dids: string[], resolver: Resolvable): Promise<Encrypter[]> {
return Promise.all(
dids.map(async (did) => {
const { didResolutionMetadata, didDocument } = await resolver.resolve(did)
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4142,10 +4142,10 @@ did-resolver@^1.0.0:
resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-1.1.0.tgz#27a63b6f2aa8dee3d622cd8b8b47360661e24f1e"
integrity sha512-Q02Sc5VuQnJzzR8fQ/DzyCHiYb31WpQdocOsxppI66wwT4XalYRDeCr3a48mL6sYPQo76AkBh0mxte9ZBuQzxA==

did-resolver@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-3.0.2.tgz#c44750b1b6536d8ea30298d1cfb3fba9eb97e5a9"
integrity sha512-1RpCnyjHrCNuUuMwJusuKtl9K7DX61uP3PHZ1qyKWflCBA9Tec+wrTDhJsCA3wQyWNRVfRn0tlhEn3z6tS53lg==
did-resolver@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-3.1.0.tgz#84f0e3d16abe9711dc04c34a5a0e2f63868c9611"
integrity sha512-uf3/4LfHoDn3Ek8bFegO72OemHMytBhAkud6CA1HlB5I0iVwrCpG4oh+DA6DXUuBdhrA0cY4cGz1D0VNDTlgnw==

diff-sequences@^26.5.0:
version "26.5.0"
Expand Down

0 comments on commit 4641e56

Please sign in to comment.