You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-13 07:42:14 +03:00
pksign was moved to olmlib
This commit is contained in:
@@ -52,7 +52,6 @@ import { isCryptoAvailable } from './crypto';
|
|||||||
import { encodeRecoveryKey, decodeRecoveryKey } from './crypto/recoverykey';
|
import { encodeRecoveryKey, decodeRecoveryKey } from './crypto/recoverykey';
|
||||||
import { keyForNewBackup, keyForExistingBackup } from './crypto/backup_password';
|
import { keyForNewBackup, keyForExistingBackup } from './crypto/backup_password';
|
||||||
import { randomString } from './randomstring';
|
import { randomString } from './randomstring';
|
||||||
import { pkSign } from './crypto/PkSigning';
|
|
||||||
|
|
||||||
import IndexedDBCryptoStore from './crypto/store/indexeddb-crypto-store';
|
import IndexedDBCryptoStore from './crypto/store/indexeddb-crypto-store';
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2019 New Vector Ltd
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const anotherjson = require('another-json');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Higher level wrapper around olm.PkSigning that signs JSON objects
|
|
||||||
* @param {Object} obj Object to sign
|
|
||||||
* @param {Uint8Array} seed The private key seed (32 bytes)
|
|
||||||
* @param {string} userId The user ID who owns the signing key
|
|
||||||
*/
|
|
||||||
export function pkSign(obj, seed, userId) {
|
|
||||||
const signing = new global.Olm.PkSigning();
|
|
||||||
try {
|
|
||||||
const pubkey = signing.init_with_seed(seed);
|
|
||||||
const sigs = obj.signatures || {};
|
|
||||||
const mysigs = sigs[userId] || {};
|
|
||||||
sigs[userId] = mysigs;
|
|
||||||
|
|
||||||
delete obj.signatures;
|
|
||||||
const unsigned = obj.unsigned;
|
|
||||||
if (obj.unsigned) delete obj.unsigned;
|
|
||||||
|
|
||||||
mysigs['ed25519:' + pubkey] = signing.sign(anotherjson.stringify(obj));
|
|
||||||
obj.signatures = sigs;
|
|
||||||
if (unsigned) obj.unsigned = unsigned;
|
|
||||||
} finally {
|
|
||||||
signing.free();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -50,8 +50,6 @@ import {
|
|||||||
newUnknownMethodError,
|
newUnknownMethodError,
|
||||||
} from './verification/Error';
|
} from './verification/Error';
|
||||||
|
|
||||||
import { pkSign } from './PkSigning';
|
|
||||||
|
|
||||||
const defaultVerificationMethods = {
|
const defaultVerificationMethods = {
|
||||||
[ScanQRCode.NAME]: ScanQRCode,
|
[ScanQRCode.NAME]: ScanQRCode,
|
||||||
[ShowQRCode.NAME]: ShowQRCode,
|
[ShowQRCode.NAME]: ShowQRCode,
|
||||||
|
|||||||
Reference in New Issue
Block a user