Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: store keypair #3

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";