This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from payid-org/clear-addresses-after-signing
change the `sign` command to clear unsigned addresses by default
- Loading branch information
Showing
4 changed files
with
111 additions
and
14 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
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 @@ | ||
import 'mocha' | ||
import { | ||
AddressDetailsType, | ||
IdentityKeySigningParams, | ||
PaymentInformation, | ||
} from '@payid-org/utils' | ||
import { assert } from 'chai' | ||
import { JWK } from 'jose' | ||
|
||
import { signPayId } from '../../src/commands/payid-sign' | ||
|
||
const info: PaymentInformation = { | ||
payId: 'boaty$mcboatface.com', | ||
addresses: [ | ||
{ | ||
paymentNetwork: 'boatcoin', | ||
environment: 'seanet', | ||
addressDetailsType: AddressDetailsType.CryptoAddress, | ||
addressDetails: { | ||
address: 'xyz12345', | ||
}, | ||
}, | ||
], | ||
verifiedAddresses: [], | ||
} | ||
|
||
describe('when signPayId()', function (): void { | ||
let signingKey: IdentityKeySigningParams | ||
|
||
beforeEach('create key', async function (): Promise<void> { | ||
const key = await JWK.generate('EC', 'P-256') | ||
signingKey = new IdentityKeySigningParams(key, 'ES256') | ||
}) | ||
|
||
it('called with keepAddresses=true, then addresses property is retained', async function (): Promise< | ||
void | ||
> { | ||
const result = signPayId(info, [signingKey], true) | ||
assert.equal(result.addresses, info.addresses) | ||
assert.lengthOf(result.verifiedAddresses, 1) | ||
}) | ||
|
||
it('called with keepAddresses=false, then addresses property is cleared', async function (): Promise< | ||
void | ||
> { | ||
const result = signPayId(info, [signingKey], false) | ||
assert.isEmpty(result.addresses) | ||
assert.lengthOf(result.verifiedAddresses, 1) | ||
}) | ||
}) |