working rss feed to nostr publish
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
import { Key } from "./Key";
|
||||
|
||||
/**
|
||||
* Represents a cryptographic operation that has been instantiated but not
|
||||
* necessarily fed all data or finalized.
|
||||
*
|
||||
* @see https://msdn.microsoft.com/en-us/library/dn280996(v=vs.85).aspx
|
||||
*/
|
||||
export interface CryptoOperation {
|
||||
readonly algorithm: string;
|
||||
readonly key: Key;
|
||||
onabort: (event: Event) => void;
|
||||
oncomplete: (event: Event) => void;
|
||||
onerror: (event: Event) => void;
|
||||
onprogress: (event: Event) => void;
|
||||
readonly result: ArrayBuffer | undefined;
|
||||
|
||||
abort(): void;
|
||||
finish(): void;
|
||||
process(buffer: ArrayBufferView): void;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* The result of a successful KeyOperation.
|
||||
*
|
||||
* @see {KeyOperation}
|
||||
* @see https://msdn.microsoft.com/en-us/library/dn302313(v=vs.85).aspx
|
||||
*/
|
||||
export interface Key {
|
||||
readonly algorithm: string;
|
||||
readonly extractable: boolean;
|
||||
readonly keyUsage: Array<string>;
|
||||
readonly type: string;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Key } from "./Key";
|
||||
|
||||
/**
|
||||
* Represents the return of a key-related operation that may or may not have
|
||||
* been completed.
|
||||
*
|
||||
* @see https://msdn.microsoft.com/en-us/library/dn302314(v=vs.85).aspx
|
||||
*/
|
||||
export interface KeyOperation {
|
||||
oncomplete: (event: Event) => void;
|
||||
onerror: (event: Event) => void;
|
||||
readonly result: Key | undefined;
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
import { CryptoOperation } from "./CryptoOperation";
|
||||
import { Key } from "./Key";
|
||||
import { KeyOperation } from "./KeyOperation";
|
||||
|
||||
export type KeyUsage =
|
||||
| "encrypt"
|
||||
| "decrypt"
|
||||
| "sign"
|
||||
| "verify"
|
||||
| "derive"
|
||||
| "wrapKey"
|
||||
| "unwrapKey"
|
||||
| "importKey";
|
||||
|
||||
export type EncryptionOrVerificationAlgorithm = "RSAES-PKCS1-v1_5";
|
||||
export type Ie11EncryptionAlgorithm =
|
||||
| "AES-CBC"
|
||||
| "AES-GCM"
|
||||
| "RSA-OAEP"
|
||||
| EncryptionOrVerificationAlgorithm;
|
||||
export type Ie11DigestAlgorithm = "SHA-1" | "SHA-256" | "SHA-384";
|
||||
|
||||
export interface HashAlgorithm {
|
||||
name: Ie11DigestAlgorithm;
|
||||
}
|
||||
|
||||
export interface HmacAlgorithm {
|
||||
name: "HMAC";
|
||||
hash: HashAlgorithm;
|
||||
}
|
||||
|
||||
export type SigningAlgorithm = HmacAlgorithm;
|
||||
|
||||
/**
|
||||
* Represent ths SubtleCrypto interface as implemented in Internet Explorer 11.
|
||||
* This implementation was based on an earlier version of the WebCrypto API and
|
||||
* differs from the `window.crypto.subtle` object exposed in Chrome, Safari,
|
||||
* Firefox, and MS Edge.
|
||||
*
|
||||
* @see https://msdn.microsoft.com/en-us/library/dn302325(v=vs.85).aspx
|
||||
*/
|
||||
export interface MsSubtleCrypto {
|
||||
decrypt(
|
||||
algorithm: Ie11EncryptionAlgorithm,
|
||||
key: Key,
|
||||
buffer?: ArrayBufferView
|
||||
): CryptoOperation;
|
||||
|
||||
digest(
|
||||
algorithm: Ie11DigestAlgorithm,
|
||||
buffer?: ArrayBufferView
|
||||
): CryptoOperation;
|
||||
|
||||
encrypt(
|
||||
algorithm: Ie11EncryptionAlgorithm,
|
||||
key: Key,
|
||||
buffer?: ArrayBufferView
|
||||
): CryptoOperation;
|
||||
|
||||
exportKey(format: string, key: Key): KeyOperation;
|
||||
|
||||
generateKey(
|
||||
algorithm: SigningAlgorithm | Ie11EncryptionAlgorithm,
|
||||
extractable?: boolean,
|
||||
keyUsages?: Array<KeyUsage>
|
||||
): KeyOperation;
|
||||
|
||||
importKey(
|
||||
format: string,
|
||||
keyData: ArrayBufferView,
|
||||
algorithm: any,
|
||||
extractable?: boolean,
|
||||
keyUsages?: Array<KeyUsage>
|
||||
): KeyOperation;
|
||||
|
||||
sign(
|
||||
algorithm: SigningAlgorithm,
|
||||
key: Key,
|
||||
buffer?: ArrayBufferView
|
||||
): CryptoOperation;
|
||||
|
||||
verify(
|
||||
algorithm: SigningAlgorithm | EncryptionOrVerificationAlgorithm,
|
||||
key: Key,
|
||||
signature: ArrayBufferView,
|
||||
buffer?: ArrayBufferView
|
||||
): CryptoOperation;
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
import { MsSubtleCrypto } from "./MsSubtleCrypto";
|
||||
|
||||
type SubtleCryptoMethod =
|
||||
| "decrypt"
|
||||
| "digest"
|
||||
| "encrypt"
|
||||
| "exportKey"
|
||||
| "generateKey"
|
||||
| "importKey"
|
||||
| "sign"
|
||||
| "verify";
|
||||
|
||||
const msSubtleCryptoMethods: Array<SubtleCryptoMethod> = [
|
||||
"decrypt",
|
||||
"digest",
|
||||
"encrypt",
|
||||
"exportKey",
|
||||
"generateKey",
|
||||
"importKey",
|
||||
"sign",
|
||||
"verify"
|
||||
];
|
||||
|
||||
/**
|
||||
* The value accessible as `window.msCrypto` in Internet Explorer 11.
|
||||
*/
|
||||
export interface MsCrypto {
|
||||
getRandomValues: (toFill: Uint8Array) => void;
|
||||
subtle: MsSubtleCrypto;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `window` object in Internet Explorer 11. This interface does not
|
||||
* exhaustively document the prefixed features of `window` in IE11.
|
||||
*/
|
||||
export interface MsWindow extends Window {
|
||||
MSInputMethodContext: any;
|
||||
msCrypto: MsCrypto;
|
||||
}
|
||||
|
||||
function quacksLikeAnMsWindow(window: Window): window is MsWindow {
|
||||
return "MSInputMethodContext" in window && "msCrypto" in window;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the provided window is (or is like) the window object one would
|
||||
* expect to encounter in Internet Explorer 11.
|
||||
*/
|
||||
export function isMsWindow(window: Window): window is MsWindow {
|
||||
if (quacksLikeAnMsWindow(window) && window.msCrypto.subtle !== undefined) {
|
||||
const { getRandomValues, subtle } = window.msCrypto;
|
||||
return msSubtleCryptoMethods
|
||||
.map<Function>(methodName => subtle[methodName])
|
||||
.concat(getRandomValues)
|
||||
.every(method => typeof method === "function");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export * from "./CryptoOperation";
|
||||
export * from "./Key";
|
||||
export * from "./KeyOperation";
|
||||
export * from "./MsSubtleCrypto";
|
||||
export * from "./MsWindow";
|
||||
Reference in New Issue
Block a user