1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00

Compare commits

...

7 commits

Author SHA1 Message Date
Kenta Moriuchi
97307f180b
Merge bbf6ce54e4 into 5e9b3712de 2025-01-21 00:04:48 +09:00
Luca Casonato
5e9b3712de
feat(unstable): add basic support for otel trace links (#27727)
Currently only links with no attributes.
2025-01-20 15:39:59 +01:00
Bartek Iwańczuk
395628026f
fix(ext/os): pass SignalState to web worker (#27741)
Closes https://github.com/denoland/deno/issues/27717

Made a mistake in https://github.com/denoland/deno/pull/27655 and
didn't add the `SignalStore` for web worker.
2025-01-20 19:43:15 +05:30
Divy Srivastava
4f27d7cdc0
fix(ext/node): GCM auth tag check on DechiperIv#final (#27733) 2025-01-20 18:16:44 +05:30
ryu
e4a16e91fa
docs(readme): update redirected links (#27726) 2025-01-20 03:01:25 +00:00
Kenta Moriuchi
bbf6ce54e4
lint 2024-11-20 03:44:30 +09:00
Kenta Moriuchi
3d7e71c59c
feat(type): make Float16Array generic 2024-11-20 03:06:16 +09:00
14 changed files with 400 additions and 226 deletions

View file

@ -6,8 +6,8 @@
<img align="right" src="https://deno.land/logo.svg" height="150px" alt="the deno mascot dinosaur standing in the rain"> <img align="right" src="https://deno.land/logo.svg" height="150px" alt="the deno mascot dinosaur standing in the rain">
[Deno](https://www.deno.com) [Deno](https://deno.com)
([/ˈdiːnoʊ/](http://ipa-reader.xyz/?text=%CB%88di%CB%90no%CA%8A), pronounced ([/ˈdiːnoʊ/](https://ipa-reader.com/?text=%CB%88di%CB%90no%CA%8A), pronounced
`dee-no`) is a JavaScript, TypeScript, and WebAssembly runtime with secure `dee-no`) is a JavaScript, TypeScript, and WebAssembly runtime with secure
defaults and a great developer experience. It's built on [V8](https://v8.dev/), defaults and a great developer experience. It's built on [V8](https://v8.dev/),
[Rust](https://www.rust-lang.org/), and [Tokio](https://tokio.rs/). [Rust](https://www.rust-lang.org/), and [Tokio](https://tokio.rs/).

View file

@ -3110,7 +3110,7 @@ declare namespace Intl {
* @category Platform * @category Platform
* @experimental * @experimental
*/ */
interface Float16Array { interface Float16Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> {
/** /**
* The size in bytes of each element in the array. * The size in bytes of each element in the array.
*/ */
@ -3119,7 +3119,7 @@ interface Float16Array {
/** /**
* The ArrayBuffer instance referenced by the array. * The ArrayBuffer instance referenced by the array.
*/ */
readonly buffer: ArrayBufferLike; readonly buffer: TArrayBuffer;
/** /**
* The length in bytes of the array. * The length in bytes of the array.
@ -3131,6 +3131,12 @@ interface Float16Array {
*/ */
readonly byteOffset: number; readonly byteOffset: number;
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
/** /**
* Returns the this object after copying a section of the array identified by start and end * Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target * to the same array starting at position target
@ -3151,7 +3157,7 @@ interface Float16Array {
* If thisArg is omitted, undefined is used as the this value. * If thisArg is omitted, undefined is used as the this value.
*/ */
every( every(
predicate: (value: number, index: number, array: Float16Array) => unknown, predicate: (value: number, index: number, array: this) => unknown,
thisArg?: any, thisArg?: any,
): boolean; ): boolean;
@ -3173,9 +3179,9 @@ interface Float16Array {
* If thisArg is omitted, undefined is used as the this value. * If thisArg is omitted, undefined is used as the this value.
*/ */
filter( filter(
predicate: (value: number, index: number, array: Float16Array) => any, predicate: (value: number, index: number, array: this) => any,
thisArg?: any, thisArg?: any,
): Float16Array; ): Float16Array<ArrayBuffer>;
/** /**
* Returns the value of the first element in the array where predicate is true, and undefined * Returns the value of the first element in the array where predicate is true, and undefined
@ -3187,7 +3193,7 @@ interface Float16Array {
* predicate. If it is not provided, undefined is used instead. * predicate. If it is not provided, undefined is used instead.
*/ */
find( find(
predicate: (value: number, index: number, obj: Float16Array) => boolean, predicate: (value: number, index: number, obj: this) => boolean,
thisArg?: any, thisArg?: any,
): number | undefined; ): number | undefined;
@ -3201,7 +3207,51 @@ interface Float16Array {
* predicate. If it is not provided, undefined is used instead. * predicate. If it is not provided, undefined is used instead.
*/ */
findIndex( findIndex(
predicate: (value: number, index: number, obj: Float16Array) => boolean, predicate: (value: number, index: number, obj: this) => boolean,
thisArg?: any,
): number;
/**
* Returns the value of the last element in the array where predicate is true, and undefined
* otherwise.
* @param predicate findLast calls predicate once for each element of the array, in descending
* order, until it finds one where predicate returns true. If such an element is found, findLast
* immediately returns that element value. Otherwise, findLast returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findLast<S extends number>(
predicate: (
value: number,
index: number,
array: this,
) => value is S,
thisArg?: any,
): S | undefined;
findLast(
predicate: (
value: number,
index: number,
array: this,
) => unknown,
thisArg?: any,
): number | undefined;
/**
* Returns the index of the last element in the array where predicate is true, and -1
* otherwise.
* @param predicate findLastIndex calls predicate once for each element of the array, in descending
* order, until it finds one where predicate returns true. If such an element is found,
* findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findLastIndex(
predicate: (
value: number,
index: number,
array: this,
) => unknown,
thisArg?: any, thisArg?: any,
): number; ): number;
@ -3213,10 +3263,17 @@ interface Float16Array {
* If thisArg is omitted, undefined is used as the this value. * If thisArg is omitted, undefined is used as the this value.
*/ */
forEach( forEach(
callbackfn: (value: number, index: number, array: Float16Array) => void, callbackfn: (value: number, index: number, array: this) => void,
thisArg?: any, thisArg?: any,
): void; ): void;
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
/** /**
* Returns the index of the first occurrence of a value in an array. * Returns the index of the first occurrence of a value in an array.
* @param searchElement The value to locate in the array. * @param searchElement The value to locate in the array.
@ -3254,9 +3311,9 @@ interface Float16Array {
* If thisArg is omitted, undefined is used as the this value. * If thisArg is omitted, undefined is used as the this value.
*/ */
map( map(
callbackfn: (value: number, index: number, array: Float16Array) => number, callbackfn: (value: number, index: number, array: this) => number,
thisArg?: any, thisArg?: any,
): Float16Array; ): Float16Array<ArrayBuffer>;
/** /**
* Calls the specified callback function for all the elements in an array. The return value of * Calls the specified callback function for all the elements in an array. The return value of
@ -3273,7 +3330,7 @@ interface Float16Array {
previousValue: number, previousValue: number,
currentValue: number, currentValue: number,
currentIndex: number, currentIndex: number,
array: Float16Array, array: this,
) => number, ) => number,
): number; ): number;
reduce( reduce(
@ -3281,7 +3338,7 @@ interface Float16Array {
previousValue: number, previousValue: number,
currentValue: number, currentValue: number,
currentIndex: number, currentIndex: number,
array: Float16Array, array: this,
) => number, ) => number,
initialValue: number, initialValue: number,
): number; ): number;
@ -3301,7 +3358,7 @@ interface Float16Array {
previousValue: U, previousValue: U,
currentValue: number, currentValue: number,
currentIndex: number, currentIndex: number,
array: Float16Array, array: this,
) => U, ) => U,
initialValue: U, initialValue: U,
): U; ): U;
@ -3321,7 +3378,7 @@ interface Float16Array {
previousValue: number, previousValue: number,
currentValue: number, currentValue: number,
currentIndex: number, currentIndex: number,
array: Float16Array, array: this,
) => number, ) => number,
): number; ): number;
reduceRight( reduceRight(
@ -3329,7 +3386,7 @@ interface Float16Array {
previousValue: number, previousValue: number,
currentValue: number, currentValue: number,
currentIndex: number, currentIndex: number,
array: Float16Array, array: this,
) => number, ) => number,
initialValue: number, initialValue: number,
): number; ): number;
@ -3349,7 +3406,7 @@ interface Float16Array {
previousValue: U, previousValue: U,
currentValue: number, currentValue: number,
currentIndex: number, currentIndex: number,
array: Float16Array, array: this,
) => U, ) => U,
initialValue: U, initialValue: U,
): U; ): U;
@ -3357,7 +3414,7 @@ interface Float16Array {
/** /**
* Reverses the elements in an Array. * Reverses the elements in an Array.
*/ */
reverse(): Float16Array; reverse(): this;
/** /**
* Sets a value or an array of values. * Sets a value or an array of values.
@ -3371,7 +3428,7 @@ interface Float16Array {
* @param start The beginning of the specified portion of the array. * @param start The beginning of the specified portion of the array.
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
*/ */
slice(start?: number, end?: number): Float16Array; slice(start?: number, end?: number): Float16Array<ArrayBuffer>;
/** /**
* Determines whether the specified callback function returns true for any element of an array. * Determines whether the specified callback function returns true for any element of an array.
@ -3382,7 +3439,7 @@ interface Float16Array {
* If thisArg is omitted, undefined is used as the this value. * If thisArg is omitted, undefined is used as the this value.
*/ */
some( some(
predicate: (value: number, index: number, array: Float16Array) => unknown, predicate: (value: number, index: number, array: this) => unknown,
thisArg?: any, thisArg?: any,
): boolean; ): boolean;
@ -3403,12 +3460,34 @@ interface Float16Array {
* @param begin The index of the beginning of the array. * @param begin The index of the beginning of the array.
* @param end The index of the end of the array. * @param end The index of the end of the array.
*/ */
subarray(begin?: number, end?: number): Float16Array; subarray(begin?: number, end?: number): Float16Array<TArrayBuffer>;
/** /**
* Converts a number to a string by using the current locale. * Converts a number to a string by using the current locale.
*/ */
toLocaleString(): string; toLocaleString(
locales?: string | string[],
options?: Intl.NumberFormatOptions,
): string;
/**
* Copies the array and returns the copy with the elements in reverse order.
*/
toReversed(): Float16Array<ArrayBuffer>;
/**
* Copies and sorts the array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* const myNums = Float16Array<Buffer>.from([11.25, 2, -22.5, 1]);
* myNums.toSorted((a, b) => a - b) // Float16Array<Buffer>(4) [-22.5, 1, 2, 11.5]
* ```
*/
toSorted(
compareFn?: (a: number, b: number) => number,
): Float16Array<ArrayBuffer>;
/** /**
* Returns a string representation of an array. * Returns a string representation of an array.
@ -3416,9 +3495,37 @@ interface Float16Array {
toString(): string; toString(): string;
/** Returns the primitive value of the specified object. */ /** Returns the primitive value of the specified object. */
valueOf(): Float16Array; valueOf(): this;
/**
* Copies the array and inserts the given number at the provided index.
* @param index The index of the value to overwrite. If the index is
* negative, then it replaces from the end of the array.
* @param value The value to insert into the copied array.
* @returns A copy of the original array with the inserted value.
*/
with(index: number, value: number): Float16Array<ArrayBuffer>;
[index: number]: number; [index: number]: number;
[Symbol.iterator](): ArrayIterator<number>;
/**
* Returns an array of key, value pairs for every entry in the array
*/
entries(): ArrayIterator<[number, number]>;
/**
* Returns an list of keys in the array
*/
keys(): ArrayIterator<number>;
/**
* Returns an list of values in the array
*/
values(): ArrayIterator<number>;
readonly [Symbol.toStringTag]: "Float16Array";
} }
/** /**
@ -3426,14 +3533,14 @@ interface Float16Array {
* @experimental * @experimental
*/ */
interface Float16ArrayConstructor { interface Float16ArrayConstructor {
readonly prototype: Float16Array; readonly prototype: Float16Array<ArrayBufferLike>;
new (length: number): Float16Array; new (length?: number): Float16Array<ArrayBuffer>;
new (array: ArrayLike<number> | ArrayBufferLike): Float16Array; new (array: ArrayLike<number> | Iterable<number>): Float16Array<ArrayBuffer>;
new ( new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(
buffer: ArrayBufferLike, buffer: TArrayBuffer,
byteOffset?: number, byteOffset?: number,
length?: number, length?: number,
): Float16Array; ): Float16Array<TArrayBuffer>;
/** /**
* The size in bytes of each element in the array. * The size in bytes of each element in the array.
@ -3444,17 +3551,17 @@ interface Float16ArrayConstructor {
* Returns a new array from a set of elements. * Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object. * @param items A set of elements to include in the new array object.
*/ */
of(...items: number[]): Float16Array; of(...items: number[]): Float16Array<ArrayBuffer>;
/** /**
* Creates an array from an array-like or iterable object. * Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array. * @param arrayLike An array-like object to convert to an array.
*/ */
from(arrayLike: ArrayLike<number>): Float16Array; from(arrayLike: ArrayLike<number>): Float16Array<ArrayBuffer>;
/** /**
* Creates an array from an array-like or iterable object. * Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array. * @param arrayLike An array-like object to convert to an array.
* @param mapfn A mapping function to call on every element of the array. * @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn. * @param thisArg Value of 'this' used to invoke the mapfn.
*/ */
@ -3462,8 +3569,27 @@ interface Float16ArrayConstructor {
arrayLike: ArrayLike<T>, arrayLike: ArrayLike<T>,
mapfn: (v: T, k: number) => number, mapfn: (v: T, k: number) => number,
thisArg?: any, thisArg?: any,
): Float16Array; ): Float16Array<ArrayBuffer>;
/**
* Creates an array from an array-like or iterable object.
* @param elements An iterable object to convert to an array.
*/
from(elements: Iterable<number>): Float16Array<ArrayBuffer>;
/**
* Creates an array from an array-like or iterable object.
* @param elements An iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T>(
elements: Iterable<T>,
mapfn?: (v: T, k: number) => number,
thisArg?: any,
): Float16Array<ArrayBuffer>;
} }
/** /**
* @category Platform * @category Platform
* @experimental * @experimental
@ -3474,169 +3600,30 @@ declare var Float16Array: Float16ArrayConstructor;
* @category Platform * @category Platform
* @experimental * @experimental
*/ */
interface Float16Array { interface Math {
[Symbol.iterator](): IterableIterator<number>;
/** /**
* Returns an array of key, value pairs for every entry in the array * Returns the nearest half precision float representation of a number.
* @param x A numeric expression.
*
* @category Platform
* @experimental
*/ */
entries(): IterableIterator<[number, number]>; f16round(x: number): number;
/**
* Returns an list of keys in the array
*/
keys(): IterableIterator<number>;
/**
* Returns an list of values in the array
*/
values(): IterableIterator<number>;
} }
/** /**
* @category Platform * @category Platform
* @experimental * @experimental
*/ */
interface Float16Constructor { interface DataView<TArrayBuffer extends ArrayBufferLike> {
new (elements: Iterable<number>): Float16Array;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(
arrayLike: Iterable<number>,
mapfn?: (v: number, k: number) => number,
thisArg?: any,
): Float16Array;
}
/**
* @category Platform
* @experimental
*/
interface Float16Array {
readonly [Symbol.toStringTag]: "Float16Array";
}
/**
* @category Platform
* @experimental
*/
interface Float16Array {
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
/**
* @category Platform
* @experimental
*/
interface Float16ArrayConstructor {
new (): Float16Array;
}
/**
* @category Platform
* @experimental
*/
interface Float16Array {
/**
* Returns the item located at the specified index.
* @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
*/
at(index: number): number | undefined;
}
/**
* @category Platform
* @experimental
*/
interface Float16Array {
/**
* Returns the value of the last element in the array where predicate is true, and undefined
* otherwise.
* @param predicate findLast calls predicate once for each element of the array, in descending
* order, until it finds one where predicate returns true. If such an element is found, findLast
* immediately returns that element value. Otherwise, findLast returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findLast<S extends number>(
predicate: (
value: number,
index: number,
array: Float16Array,
) => value is S,
thisArg?: any,
): S | undefined;
findLast(
predicate: (
value: number,
index: number,
array: Float16Array,
) => unknown,
thisArg?: any,
): number | undefined;
/**
* Returns the index of the last element in the array where predicate is true, and -1
* otherwise.
* @param predicate findLastIndex calls predicate once for each element of the array, in descending
* order, until it finds one where predicate returns true. If such an element is found,
* findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findLastIndex(
predicate: (
value: number,
index: number,
array: Float16Array,
) => unknown,
thisArg?: any,
): number;
/**
* Copies the array and returns the copy with the elements in reverse order.
*/
toReversed(): Float16Array;
/**
* Copies and sorts the array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* const myNums = Float16Array.from([11.25, 2, -22.5, 1]);
* myNums.toSorted((a, b) => a - b) // Float16Array(4) [-22.5, 1, 2, 11.5]
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Float16Array;
/**
* Copies the array and inserts the given number at the provided index.
* @param index The index of the value to overwrite. If the index is
* negative, then it replaces from the end of the array.
* @param value The value to insert into the copied array.
* @returns A copy of the original array with the inserted value.
*/
with(index: number, value: number): Float16Array;
}
/**
* @category Platform
* @experimental
*/
interface DataView {
/** /**
* Gets the Float16 value at the specified byte offset from the start of the view. There is * Gets the Float16 value at the specified byte offset from the start of the view. There is
* no alignment constraint; multi-byte values may be fetched from any offset. * no alignment constraint; multi-byte values may be fetched from any offset.
* @param byteOffset The place in the buffer at which the value should be retrieved. * @param byteOffset The place in the buffer at which the value should be retrieved.
* @param littleEndian If false or undefined, a big-endian value should be read. * @param littleEndian If false or undefined, a big-endian value should be read.
*
* @category Platform
* @experimental
*/ */
getFloat16(byteOffset: number, littleEndian?: boolean): number; getFloat16(byteOffset: number, littleEndian?: boolean): number;
@ -3645,6 +3632,9 @@ interface DataView {
* @param byteOffset The place in the buffer at which the value should be set. * @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set. * @param value The value to set.
* @param littleEndian If false or undefined, a big-endian value should be written. * @param littleEndian If false or undefined, a big-endian value should be written.
*
* @category Platform
* @experimental
*/ */
setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void; setFloat16(byteOffset: number, value: number, littleEndian?: boolean): void;
} }

View file

@ -226,7 +226,6 @@ deno_core::extension!(deno_node,
ops::crypto::op_node_decipheriv_decrypt, ops::crypto::op_node_decipheriv_decrypt,
ops::crypto::op_node_decipheriv_final, ops::crypto::op_node_decipheriv_final,
ops::crypto::op_node_decipheriv_set_aad, ops::crypto::op_node_decipheriv_set_aad,
ops::crypto::op_node_decipheriv_take,
ops::crypto::op_node_dh_compute_secret, ops::crypto::op_node_dh_compute_secret,
ops::crypto::op_node_diffie_hellman, ops::crypto::op_node_diffie_hellman,
ops::crypto::op_node_ecdh_compute_public_key, ops::crypto::op_node_ecdh_compute_public_key,

View file

@ -500,6 +500,11 @@ impl Decipher {
auth_tag: &[u8], auth_tag: &[u8],
) -> Result<(), DecipherError> { ) -> Result<(), DecipherError> {
use Decipher::*; use Decipher::*;
if input.is_empty() && !matches!(self, Aes128Gcm(_) | Aes256Gcm(_)) {
return Ok(());
}
match (self, auto_pad) { match (self, auto_pad) {
(Aes128Cbc(decryptor), true) => { (Aes128Cbc(decryptor), true) => {
assert!(input.len() == 16); assert!(input.len() == 16);

View file

@ -332,17 +332,6 @@ pub fn op_node_decipheriv_decrypt(
true true
} }
#[op2(fast)]
pub fn op_node_decipheriv_take(
state: &mut OpState,
#[smi] rid: u32,
) -> Result<(), cipher::DecipherContextError> {
let context = state.resource_table.take::<cipher::DecipherContext>(rid)?;
Rc::try_unwrap(context)
.map_err(|_| cipher::DecipherContextError::ContextInUse)?;
Ok(())
}
#[op2] #[op2]
pub fn op_node_decipheriv_final( pub fn op_node_decipheriv_final(
state: &mut OpState, state: &mut OpState,

View file

@ -18,7 +18,6 @@ import {
op_node_decipheriv_decrypt, op_node_decipheriv_decrypt,
op_node_decipheriv_final, op_node_decipheriv_final,
op_node_decipheriv_set_aad, op_node_decipheriv_set_aad,
op_node_decipheriv_take,
op_node_private_decrypt, op_node_private_decrypt,
op_node_private_encrypt, op_node_private_encrypt,
op_node_public_encrypt, op_node_public_encrypt,
@ -352,14 +351,6 @@ export class Decipheriv extends Transform implements Cipher {
} }
final(encoding: string = getDefaultEncoding()): Buffer | string { final(encoding: string = getDefaultEncoding()): Buffer | string {
if (!this.#needsBlockCache || this.#cache.cache.byteLength === 0) {
op_node_decipheriv_take(this.#context);
return encoding === "buffer" ? Buffer.from([]) : "";
}
if (this.#cache.cache.byteLength != 16) {
throw new Error("Invalid final block size");
}
let buf = new Buffer(16); let buf = new Buffer(16);
op_node_decipheriv_final( op_node_decipheriv_final(
this.#context, this.#context,
@ -369,6 +360,13 @@ export class Decipheriv extends Transform implements Cipher {
this.#authTag || NO_TAG, this.#authTag || NO_TAG,
); );
if (!this.#needsBlockCache || this.#cache.cache.byteLength === 0) {
return encoding === "buffer" ? Buffer.from([]) : "";
}
if (this.#cache.cache.byteLength != 16) {
throw new Error("Invalid final block size");
}
buf = buf.subarray(0, 16 - buf.at(-1)); // Padded in Pkcs7 mode buf = buf.subarray(0, 16 - buf.at(-1)); // Padded in Pkcs7 mode
return encoding === "buffer" ? buf : buf.toString(encoding); return encoding === "buffer" ? buf : buf.toString(encoding);
} }

View file

@ -116,6 +116,12 @@ deno_core::extension!(
"op_exit" | "op_set_exit_code" | "op_get_exit_code" => "op_exit" | "op_set_exit_code" | "op_get_exit_code" =>
op.with_implementation_from(&deno_core::op_void_sync()), op.with_implementation_from(&deno_core::op_void_sync()),
_ => op, _ => op,
},
state = |state| {
#[cfg(unix)]
{
state.put(ops::signal::SignalState::default());
}
} }
); );

View file

@ -42,6 +42,7 @@ use opentelemetry::metrics::InstrumentBuilder;
use opentelemetry::metrics::MeterProvider as _; use opentelemetry::metrics::MeterProvider as _;
use opentelemetry::otel_debug; use opentelemetry::otel_debug;
use opentelemetry::otel_error; use opentelemetry::otel_error;
use opentelemetry::trace::Link;
use opentelemetry::trace::SpanContext; use opentelemetry::trace::SpanContext;
use opentelemetry::trace::SpanId; use opentelemetry::trace::SpanId;
use opentelemetry::trace::SpanKind; use opentelemetry::trace::SpanKind;
@ -94,6 +95,7 @@ deno_core::extension!(
op_otel_span_attribute1, op_otel_span_attribute1,
op_otel_span_attribute2, op_otel_span_attribute2,
op_otel_span_attribute3, op_otel_span_attribute3,
op_otel_span_add_link,
op_otel_span_update_name, op_otel_span_update_name,
op_otel_metric_attribute3, op_otel_metric_attribute3,
op_otel_metric_record0, op_otel_metric_record0,
@ -1324,17 +1326,6 @@ impl OtelSpan {
} }
} }
#[fast]
fn drop_link(&self) {
let mut state = self.0.borrow_mut();
match &mut **state {
OtelSpanState::Recording(span) => {
span.links.dropped_count += 1;
}
OtelSpanState::Done(_) => {}
}
}
#[fast] #[fast]
fn end(&self, end_time: f64) { fn end(&self, end_time: f64) {
let end_time = if end_time.is_nan() { let end_time = if end_time.is_nan() {
@ -1448,6 +1439,48 @@ fn op_otel_span_update_name<'s>(
} }
} }
#[op2(fast)]
fn op_otel_span_add_link<'s>(
scope: &mut v8::HandleScope<'s>,
span: v8::Local<'s, v8::Value>,
trace_id: v8::Local<'s, v8::Value>,
span_id: v8::Local<'s, v8::Value>,
#[smi] trace_flags: u8,
is_remote: bool,
#[smi] dropped_attributes_count: u32,
) -> bool {
let trace_id = parse_trace_id(scope, trace_id);
if trace_id == TraceId::INVALID {
return false;
};
let span_id = parse_span_id(scope, span_id);
if span_id == SpanId::INVALID {
return false;
};
let span_context = SpanContext::new(
trace_id,
span_id,
TraceFlags::new(trace_flags),
is_remote,
TraceState::NONE,
);
let Some(span) =
deno_core::_ops::try_unwrap_cppgc_object::<OtelSpan>(scope, span)
else {
return true;
};
let mut state = span.0.borrow_mut();
if let OtelSpanState::Recording(span) = &mut **state {
span.links.links.push(Link::new(
span_context,
vec![],
dropped_attributes_count,
));
}
true
}
struct OtelMeter(opentelemetry::metrics::Meter); struct OtelMeter(opentelemetry::metrics::Meter);
impl deno_core::GarbageCollected for OtelMeter {} impl deno_core::GarbageCollected for OtelMeter {}

View file

@ -15,6 +15,7 @@ import {
op_otel_metric_record2, op_otel_metric_record2,
op_otel_metric_record3, op_otel_metric_record3,
op_otel_metric_wait_to_observe, op_otel_metric_wait_to_observe,
op_otel_span_add_link,
op_otel_span_attribute1, op_otel_span_attribute1,
op_otel_span_attribute2, op_otel_span_attribute2,
op_otel_span_attribute3, op_otel_span_attribute3,
@ -186,7 +187,6 @@ interface OtelSpan {
spanContext(): SpanContext; spanContext(): SpanContext;
setStatus(status: SpanStatusCode, errorDescription: string): void; setStatus(status: SpanStatusCode, errorDescription: string): void;
dropEvent(): void; dropEvent(): void;
dropLink(): void;
end(endTime: number): void; end(endTime: number): void;
} }
@ -359,14 +359,24 @@ class Span {
return this; return this;
} }
addLink(_link: Link): Span { addLink(link: Link): Span {
this.#otelSpan?.dropLink(); const droppedAttributeCount = (link.droppedAttributesCount ?? 0) +
(link.attributes ? ObjectKeys(link.attributes).length : 0);
const valid = op_otel_span_add_link(
this.#otelSpan,
link.context.traceId,
link.context.spanId,
link.context.traceFlags,
link.context.isRemote ?? false,
droppedAttributeCount,
);
if (!valid) return this;
return this; return this;
} }
addLinks(links: Link[]): Span { addLinks(links: Link[]): Span {
for (let i = 0; i < links.length; i++) { for (let i = 0; i < links.length; i++) {
this.#otelSpan?.dropLink(); this.addLink(links[i]);
} }
return this; return this;
} }

View file

@ -22,6 +22,10 @@
}, },
"args": "run -A main.ts metric.ts", "args": "run -A main.ts metric.ts",
"output": "metric.out" "output": "metric.out"
},
"links": {
"args": "run -A main.ts links.ts",
"output": "links.out"
} }
} }
} }

View file

@ -0,0 +1,96 @@
{
"spans": [
{
"traceId": "00000000000000000000000000000001",
"spanId": "0000000000000001",
"traceState": "",
"parentSpanId": "",
"flags": 1,
"name": "example span",
"kind": 1,
"startTimeUnixNano": "[WILDCARD]",
"endTimeUnixNano": "[WILDCARD]",
"attributes": [],
"droppedAttributesCount": 0,
"events": [],
"droppedEventsCount": 0,
"links": [
{
"traceId": "1234567890abcdef1234567890abcdef",
"spanId": "1234567890abcdef",
"traceState": "",
"attributes": [],
"droppedAttributesCount": 0,
"flags": 1
}
],
"droppedLinksCount": 0,
"status": {
"message": "",
"code": 0
}
},
{
"traceId": "00000000000000000000000000000002",
"spanId": "0000000000000002",
"traceState": "",
"parentSpanId": "",
"flags": 1,
"name": "example span",
"kind": 1,
"startTimeUnixNano": "[WILDCARD]",
"endTimeUnixNano": "[WILDCARD]",
"attributes": [],
"droppedAttributesCount": 0,
"events": [],
"droppedEventsCount": 0,
"links": [
{
"traceId": "1234567890abcdef1234567890abcdef",
"spanId": "1234567890abcdef",
"traceState": "",
"attributes": [],
"droppedAttributesCount": 0,
"flags": 1
}
],
"droppedLinksCount": 0,
"status": {
"message": "",
"code": 0
}
},
{
"traceId": "00000000000000000000000000000003",
"spanId": "0000000000000003",
"traceState": "",
"parentSpanId": "",
"flags": 1,
"name": "example span",
"kind": 1,
"startTimeUnixNano": "[WILDCARD]",
"endTimeUnixNano": "[WILDCARD]",
"attributes": [],
"droppedAttributesCount": 0,
"events": [],
"droppedEventsCount": 0,
"links": [
{
"traceId": "1234567890abcdef1234567890abcdef",
"spanId": "1234567890abcdef",
"traceState": "",
"attributes": [],
"droppedAttributesCount": 2,
"flags": 1
}
],
"droppedLinksCount": 0,
"status": {
"message": "",
"code": 0
}
}
],
"logs": [],
"metrics": []
}

View file

@ -0,0 +1,40 @@
// Copyright 2018-2025 the Deno authors. MIT license.
import { trace } from "npm:@opentelemetry/api@1.9.0";
const tracer = trace.getTracer("example-tracer");
const span1 = tracer.startSpan("example span", {
links: [{
context: {
traceId: "1234567890abcdef1234567890abcdef",
spanId: "1234567890abcdef",
traceFlags: 1,
},
}],
});
span1.end();
const span2 = tracer.startSpan("example span");
span2.addLink({
context: {
traceId: "1234567890abcdef1234567890abcdef",
spanId: "1234567890abcdef",
traceFlags: 1,
},
});
span2.end();
const span3 = tracer.startSpan("example span");
span3.addLink({
context: {
traceId: "1234567890abcdef1234567890abcdef",
spanId: "1234567890abcdef",
traceFlags: 1,
},
attributes: {
key: "value",
},
droppedAttributesCount: 1,
});
span3.end();

View file

@ -4,7 +4,7 @@ import crypto from "node:crypto";
import { Buffer } from "node:buffer"; import { Buffer } from "node:buffer";
import testVectors128 from "./gcmEncryptExtIV128.json" with { type: "json" }; import testVectors128 from "./gcmEncryptExtIV128.json" with { type: "json" };
import testVectors256 from "./gcmEncryptExtIV256.json" with { type: "json" }; import testVectors256 from "./gcmEncryptExtIV256.json" with { type: "json" };
import { assertEquals } from "@std/assert"; import { assertEquals, assertThrows } from "@std/assert";
const aesGcm = (bits: string, key: Uint8Array) => { const aesGcm = (bits: string, key: Uint8Array) => {
const ALGO = bits == "128" ? `aes-128-gcm` : `aes-256-gcm`; const ALGO = bits == "128" ? `aes-128-gcm` : `aes-256-gcm`;
@ -123,7 +123,7 @@ Deno.test({
// Issue #27441 // Issue #27441
// https://github.com/denoland/deno/issues/27441 // https://github.com/denoland/deno/issues/27441
Deno.test({ Deno.test({
name: "aes-256-gcm supports IV of non standard length", name: "aes-256-gcm supports IV of non standard length and auth tag check",
fn() { fn() {
const decipher = crypto.createDecipheriv( const decipher = crypto.createDecipheriv(
"aes-256-gcm", "aes-256-gcm",
@ -136,6 +136,10 @@ Deno.test({
"utf-8", "utf-8",
); );
assertEquals(decrypted, "this is a secret"); assertEquals(decrypted, "this is a secret");
decipher.final(); assertThrows(
() => decipher.final(),
TypeError,
"Failed to authenticate data",
);
}, },
}); });

View file

@ -48,8 +48,8 @@ const packages: Package[] = [{
const markdownText = `# Deno const markdownText = `# Deno
[Deno](https://www.deno.com) [Deno](https://deno.com)
([/ˈdiːnoʊ/](http://ipa-reader.xyz/?text=%CB%88di%CB%90no%CA%8A), pronounced ([/ˈdiːnoʊ/](https://ipa-reader.com/?text=%CB%88di%CB%90no%CA%8A), pronounced
\`dee-no\`) is a JavaScript, TypeScript, and WebAssembly runtime with secure \`dee-no\`) is a JavaScript, TypeScript, and WebAssembly runtime with secure
defaults and a great developer experience. It's built on [V8](https://v8.dev/), defaults and a great developer experience. It's built on [V8](https://v8.dev/),
[Rust](https://www.rust-lang.org/), and [Tokio](https://tokio.rs/). [Rust](https://www.rust-lang.org/), and [Tokio](https://tokio.rs/).