Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazonアプリストア
Ring
AWS
ドキュメント
Support
Contact Us
My Cases
開発
設計と開発
公開
リファレンス
サポート

WebCrypto

WebCrypto

コンストラクタ

new WebCrypto()

new WebCrypto(): WebCrypto

戻り値

WebCrypto

プロパティ

subtle

static subtle: typeof (Anonymous class) = `class { static async importKey(format: KeyFormat, data: ArrayBuffer | Uint8Array | DataView, algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: Array) : Promise { // Only 'raw' format is implemented. return new Promise((resolve, reject) => { let key : ArrayBuffer; let keyData : ArrayBuffer; // WebCryptoの仕様により、キーのディープコピーを作成してください。// 参照: (ポイント2.2) // https://www.w3.org/TR/WebCryptoAPI/#dfn-SubtleCrypto-method-importKey if (data instanceof ArrayBuffer) { keyData = new Uint8Array(data).buffer; key = data; } else if(data instanceof Uint8Array || data instanceof DataView ) { keyData = new Uint8Array(data.buffer).buffer; key = data.buffer; } else { LogUtil.error("WebCrypto::importKey(): data type error"); reject(); } let keyObj: CryptoKeyObject = W3CMediaTurboModule.importKey(format, keyData, algorithm, extractable, keyUsages); // 現時点では、JSONObjectに配列を追加したものに相当する // ネイティブなオブジェクトはないため、ここでキーと使用法を割り当てます。 if (extractable) { keyObj.key = key; } keyObj.usages = keyUsages; keyObj.algorithm = algorithm; let result: CryptoKey = keyObj; if (result.usages.length >= 1) { resolve(result); return; } reject(); }); }

    static async decrypt(algorithm: AlgorithmIdentifier, key: CryptoKey,
                         data: BufferSource) : Promise<any> {
        return new Promise<ArrayBuffer>((resolve, reject) => {
            if (algorithm === undefined || key === undefined ||
                (algorithm.name !== "AES-CTR" && algorithm.iv === undefined && key.algorithm.iv === undefined) ||
                (algorithm.name === "AES-CTR" && algorithm.counter === undefined && key.algorithm.counter === undefined) ||
                data === undefined) {
                LogUtil.error("WebCrypto::decrypt invalid data passed");
                reject();
            }
            let ivCounterArray : ArrayBuffer;
            if (algorithm.name === "AES-CTR") {
                if (algorithm.counter instanceof ArrayBuffer) {
                    ivCounterArray = algorithm.counter;
                } else {
                    if (algorithm.counter.byteOffset == 0 && algorithm.counter.byteLength == algorithm.counter.buffer.byteLength) {
                        // これはバッファー全体にわたるTypedArrayです。
                        ivCounterArray = algorithm.counter.buffer;
                    } else {
                        // これはバッファーの「ビュー」です。 データのみを含む新しいバッファーを作成
                        // します。 これはArrayBufferではないため、「new」呼び出しにより、
                        // コピーを格納する新しいバッファーが割り当てられることに注意してください。
                        ivCounterArray = new Uint8Array(algorithm.counter.buffer).buffer;
                    }
                }
            }
            else {
                if (algorithm.iv instanceof ArrayBuffer) {
                    ivCounterArray = algorithm.iv;
                } else {
                    if (algorithm.iv.byteOffset == 0 && algorithm.iv.byteLength == algorithm.iv.buffer.byteLength) {
                        // これはバッファー全体にわたるTypedArrayです。
                        ivCounterArray = algorithm.iv.buffer;
                    } else {
                        // これはバッファーの「ビュー」です。 データのみを含む新しいバッファーを作成
                        // します。 これはArrayBufferではないため、「new」呼び出しにより、
                        // コピーを格納する新しいバッファーが割り当てられることに注意してください。
                        ivCounterArray = new Uint8Array(algorithm.iv.buffer).buffer;
                    }
                }
            }
            // ivArrayをCryptoKeyにコピーします。
            key.algorithm.iv = ivCounterArray;
            let plainData: ArrayBuffer = W3CMediaTurboModule.decrypt(key.algorithm, key, ivCounterArray, data);
            if (plainData.byteLength >= 1) {
                resolve(plainData);
                return;
            }
            LogUtil.error("WebCrypto::decrypt Errored out");
            reject();
        });
    }
}`

メソッド

randomUUID()

static randomUUID(): string

戻り値

string


Last updated: 2026年7月22日