Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#70928 add oidc-token-hash by @panva
Browse files Browse the repository at this point in the history
  • Loading branch information
panva authored Oct 18, 2024
1 parent ce1c79a commit 0a3f523
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
5 changes: 5 additions & 0 deletions types/oidc-token-hash/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
8 changes: 8 additions & 0 deletions types/oidc-token-hash/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface Names {
claim: string;
source: string;
}

export function generate(token: string, alg: string, crv?: string): string;

export function validate(names: Names, actual: string, source: string, alg: string, crv?: string): void;
9 changes: 9 additions & 0 deletions types/oidc-token-hash/oidc-token-hash-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as oidcTokenHash from "oidc-token-hash";

oidcTokenHash.validate({ claim: "at_hash", source: "access_token" }, "x7vk7f6BvQj0jQHYFIk4ag", "token", "RS256"); // $ExpectType void
oidcTokenHash.validate({ claim: "at_hash", source: "access_token" }, "x7vk7f6BvQj0jQHYFIk4ag", "foobar", "RS256"); // $ExpectType void
oidcTokenHash.generate("token", "RS256"); // $ExpectType string
oidcTokenHash.generate("token", "HS384"); // $ExpectType string
oidcTokenHash.generate("token", "ES512"); // $ExpectType string
oidcTokenHash.generate("token", "EdDSA", "Ed25519"); // $ExpectType string
oidcTokenHash.generate("token", "EdDSA", "Ed448"); // $ExpectType string
17 changes: 17 additions & 0 deletions types/oidc-token-hash/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"private": true,
"name": "@types/oidc-token-hash",
"version": "5.0.9999",
"projects": [
"https://github.com/panva/oidc-token-hash"
],
"devDependencies": {
"@types/oidc-token-hash": "workspace:."
},
"owners": [
{
"name": "Filip Skokan",
"githubUsername": "panva"
}
]
}
19 changes: 19 additions & 0 deletions types/oidc-token-hash/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "node16",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"oidc-token-hash-tests.ts"
]
}

0 comments on commit 0a3f523

Please sign in to comment.