Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
fix: store keypair
Browse files Browse the repository at this point in the history
  • Loading branch information
kyxyes committed Feb 27, 2023
1 parent 5e741ab commit 22d36af
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 12 deletions.
6 changes: 6 additions & 0 deletions docs/oidc-client-ts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ export type CreateSignoutRequestArgs = Omit<SignoutRequestArgs, "url" | "state_d
state?: unknown;
};

// @public (undocumented)
export const DpopKeypair: {
publicKey: null;
privateKey: null;
};

// @public
export class ErrorResponse extends Error {
constructor(args: {
Expand Down
93 changes: 84 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
"dependencies": {
"crypto-js": "^4.1.1",
"dpop": "^1.1.0",
"jwt-decode": "^3.1.2"
"jose": "^4.12.0",
"jwt-decode": "^3.1.2",
"pem-jwk": "^2.0.0"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.18.10",
Expand Down
14 changes: 12 additions & 2 deletions src/TokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { CryptoUtils, Logger } from "./utils";
import { JsonService } from "./JsonService";
import type { MetadataService } from "./MetadataService";
import type { OidcClientSettingsStore } from "./OidcClientSettings";
import DPoP, { JWSAlgorithm, generateKeyPair } from "dpop";
import DPoP, { generateKeyPair } from "dpop";

// Tempeory solution, store dpop keypair in memory
const DpopKeypair = {
publicKey: null,
privateKey: null,
};
export { DpopKeypair } ;

/**
* @internal
Expand Down Expand Up @@ -65,7 +72,10 @@ const buildDPoPHeader = async (url: string, method: string, token: any) =>{
undefined,
token,
);


DpopKeypair.publicKey = keypair.publicKey as any;
DpopKeypair.privateKey = keypair.privateKey as any;

return dpop;
};

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ export { UserManagerSettingsStore } from "./UserManagerSettings";
export type { UserManagerSettings } from "./UserManagerSettings";
export { Version } from "./Version";
export { WebStorageStateStore } from "./WebStorageStateStore";
export { DpopKeypair } from "./TokenClient";

0 comments on commit 22d36af

Please sign in to comment.