Skip to content

Commit 58a7440

Browse files
sirtimidclaude
andcommitted
feat: Export endowment factories via sub-path
Add `@metamask/snaps-execution-environments/endowments` sub-path export that exposes generic endowment factory modules (timeout, interval, date, textEncoder, textDecoder, crypto, math) for reuse in other SES-based projects like ocap-kernel. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a3872c4 commit 58a7440

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

packages/snaps-execution-environments/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Export endowment factories via `@metamask/snaps-execution-environments/endowments` sub-path ([#XXXX](https://github.com/MetaMask/snaps/pull/XXXX))
13+
- Exports endowment factory modules: `timeout`, `interval`, `date`, `textEncoder`, `textDecoder`, `crypto`, `math`
14+
1015
## [11.0.2]
1116

1217
### Changed

packages/snaps-execution-environments/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@
2828
"default": "./dist/index.cjs"
2929
}
3030
},
31+
"./endowments": {
32+
"import": {
33+
"types": "./dist/endowments.d.mts",
34+
"default": "./dist/endowments.mjs"
35+
},
36+
"require": {
37+
"types": "./dist/endowments.d.cts",
38+
"default": "./dist/endowments.cjs"
39+
}
40+
},
3141
"./node-process": "./dist/webpack/node-process/bundle.js",
3242
"./node-thread": "./dist/webpack/node-thread/bundle.js",
3343
"./package.json": "./package.json"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Public endowment factory exports for use outside the Snaps ecosystem.
3+
*
4+
* Each module provides a `names` array and a `factory` function. Call
5+
* `factory()` to obtain hardened endowment values (and an optional
6+
* `teardownFunction` for timer-based endowments).
7+
*
8+
* @example
9+
* ```ts
10+
* import { timeout, date } from '@metamask/snaps-execution-environments/endowments';
11+
*
12+
* const timers = timeout.factory();
13+
* // { setTimeout, clearTimeout, teardownFunction }
14+
*
15+
* const dateEndowment = date.factory();
16+
* // { Date } (with noise-added Date.now)
17+
* ```
18+
*
19+
* @module endowments
20+
*/
21+
22+
// Individual endowment factory modules
23+
export { default as timeout } from './common/endowments/timeout';
24+
export { default as interval } from './common/endowments/interval';
25+
export { default as date } from './common/endowments/date';
26+
export { default as textEncoder } from './common/endowments/textEncoder';
27+
export { default as textDecoder } from './common/endowments/textDecoder';
28+
export { default as crypto } from './common/endowments/crypto';
29+
export { default as math } from './common/endowments/math';

0 commit comments

Comments
 (0)