-
-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CustomKey for a customized signing and verifying
- Loading branch information
1 parent
c11a9d3
commit b7efe59
Showing
6 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const { | ||
JWK_MEMBERS, PUBLIC_MEMBERS, PRIVATE_MEMBERS | ||
} = require('../../help/consts') | ||
|
||
const Key = require('./base') | ||
|
||
const CUSTOM_PUBLIC = new Set([]) | ||
Object.freeze(CUSTOM_PUBLIC) | ||
const CUSTOM_PRIVATE = new Set([...CUSTOM_PUBLIC]) | ||
Object.freeze(CUSTOM_PRIVATE) | ||
|
||
class CustomKeyObject { | ||
constructor (params) { | ||
params = params || {} | ||
|
||
this._type = params.keyType | ||
this._symmetricKeySize = params.symmetricKeySize || 0 | ||
} | ||
|
||
get type () { | ||
return this._type | ||
} | ||
|
||
get symmetricKeySize () { | ||
return this._symmetricKeySize | ||
} | ||
} | ||
|
||
// Custom Key Type | ||
class CustomKey extends Key { | ||
constructor (params) { | ||
// { alg, use, kid, key_ops: ops, x5c, x5t, 'x5t#S256', keyType, symmetricKeySize } = {} | ||
super(new CustomKeyObject(params), Object.assign(params || {}, { custom: true })) | ||
this[JWK_MEMBERS]() | ||
} | ||
|
||
static get [PUBLIC_MEMBERS] () { | ||
return CUSTOM_PUBLIC | ||
} | ||
|
||
static get [PRIVATE_MEMBERS] () { | ||
return CUSTOM_PRIVATE | ||
} | ||
|
||
algorithms (operation, /* second argument is private API */ { use = this.use, alg = this.alg, key_ops: ops = this.key_ops } = {}) { | ||
// Should override | ||
} | ||
} | ||
|
||
module.exports = CustomKey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters