@owlmeans/basic-envelope 0.1.18-rc.45 → 0.1.18-rc.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/basic-envelope/SKILL.md +3 -3
- package/build/model.js +4 -4
- package/build/model.js.map +1 -1
- package/build/utils/envelope/types.d.ts +9 -0
- package/build/utils/envelope/types.d.ts.map +1 -0
- package/build/utils/{types.js.map → envelope/types.js.map} +1 -1
- package/build/utils/envelope.d.ts +4 -0
- package/build/utils/envelope.d.ts.map +1 -0
- package/build/utils/envelope.js +10 -0
- package/build/utils/envelope.js.map +1 -0
- package/build/utils/index.d.ts +1 -1
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/model.d.ts +4 -17
- package/build/utils/model.d.ts.map +1 -1
- package/build/utils/model.js +4 -6
- package/build/utils/model.js.map +1 -1
- package/package.json +3 -3
- package/src/model.ts +4 -4
- package/src/utils/envelope/types.ts +9 -0
- package/src/utils/envelope.ts +21 -0
- package/src/utils/index.ts +1 -1
- package/build/utils/types.d.ts +0 -3
- package/build/utils/types.d.ts.map +0 -1
- package/src/utils/model.ts +0 -18
- package/src/utils/types.ts +0 -3
- /package/build/utils/{types.js → envelope/types.js} +0 -0
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Type-safe message envelope with TTL, signing, and Base64 encoding for cross-serv
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
bun add @owlmeans/basic-envelope@^0.1.18-rc.
|
|
14
|
+
bun add @owlmeans/basic-envelope@^0.1.18-rc.47
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
@@ -80,7 +80,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
80
80
|
your project's skill store (`.agents/skills/`):
|
|
81
81
|
|
|
82
82
|
```sh
|
|
83
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
83
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.51
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/basic-envelope",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.47",
|
|
5
|
+
"generatedAt": "2026-10-06T11:45:57.688Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/basic-envelope
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/basic-envelope": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/basic-envelope": "^0.1.18-rc.47"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
An envelope is a signed, self-expiring container: a type tag, an encoded message, a timestamp and a
|
|
14
14
|
TTL, plus the signature over all of it. It is what carries auth challenges and tokens between
|
|
@@ -36,7 +36,7 @@ the model**, so the chained form is the idiomatic one.
|
|
|
36
36
|
```typescript
|
|
37
37
|
import { makeEnvelopeModel, EnvelopeKind } from '@owlmeans/basic-envelope'
|
|
38
38
|
import { RELY_3RD, type RelyToken } from '@owlmeans/auth'
|
|
39
|
-
import {
|
|
39
|
+
import { keyHelper, makeKeyPairModel } from '@owlmeans/basic-keys'
|
|
40
40
|
|
|
41
41
|
const key = makeKeyPairModel(privateKey)
|
|
42
42
|
|
|
@@ -68,7 +68,7 @@ Pass the serialized string as the first argument together with the kind it was p
|
|
|
68
68
|
const received = makeEnvelopeModel<RelyToken>(token, EnvelopeKind.Token)
|
|
69
69
|
|
|
70
70
|
if (received.type() !== RELY_3RD) { /* wrong kind of message */ }
|
|
71
|
-
if (!await received.verify(fromPubKey(publicKey))) { /* forged or expired */ }
|
|
71
|
+
if (!await received.verify(keyHelper.fromPubKey(publicKey))) { /* forged or expired */ }
|
|
72
72
|
|
|
73
73
|
const rely = received.message() // decoded payload
|
|
74
74
|
const raw = received.message(true) // the encoded string, untouched
|
package/build/model.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { base64, utf8 } from '@scure/base';
|
|
2
2
|
import { DEFAULT_TTL, EnvelopeKind } from './consts.js';
|
|
3
|
-
import {
|
|
3
|
+
import { envelopeUtils } from './utils/envelope.js';
|
|
4
4
|
export const makeEnvelopeModel = (type, kind) => {
|
|
5
5
|
const model = {
|
|
6
6
|
envelope: kind == null ? {
|
|
@@ -9,7 +9,7 @@ export const makeEnvelopeModel = (type, kind) => {
|
|
|
9
9
|
dt: new Date().getTime(),
|
|
10
10
|
ttl: DEFAULT_TTL
|
|
11
11
|
} : kind === EnvelopeKind.Wrap
|
|
12
|
-
?
|
|
12
|
+
? envelopeUtils.unwrap(type) : envelopeUtils.untokenize(type),
|
|
13
13
|
send: (msg, ttl) => {
|
|
14
14
|
model.envelope.msg = typeof msg == 'string' ? msg : base64.encode(utf8.decode(JSON.stringify(msg)));
|
|
15
15
|
if (typeof ttl !== 'undefined') {
|
|
@@ -29,8 +29,8 @@ export const makeEnvelopeModel = (type, kind) => {
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
type: () => model.envelope.t,
|
|
32
|
-
wrap: () =>
|
|
33
|
-
tokenize: () =>
|
|
32
|
+
wrap: () => envelopeUtils.wrap(model.envelope),
|
|
33
|
+
tokenize: () => envelopeUtils.tokenize(model.envelope),
|
|
34
34
|
sign: async (key, kind) => {
|
|
35
35
|
model.envelope.sig = await key.sign(model.envelope);
|
|
36
36
|
switch (kind) {
|
package/build/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Envelope } from '../../types.js';
|
|
2
|
+
/** The two serialized forms of an envelope: wrapped (base64) and tokenized (base64url). */
|
|
3
|
+
export interface EnvelopeUtils {
|
|
4
|
+
wrap: (object: Envelope) => string;
|
|
5
|
+
tokenize: (object: Envelope) => string;
|
|
6
|
+
untokenize: (token: string) => Envelope;
|
|
7
|
+
unwrap: (envelope: string) => Envelope;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/envelope/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,MAAM,CAAA;IAClC,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,MAAM,CAAA;IACtC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,QAAQ,CAAA;IACvC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,QAAQ,CAAA;CACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/envelope/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/utils/envelope.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,eAAO,MAAM,mBAAmB,QAAO,aActC,CAAA;AAED,eAAO,MAAM,aAAa,eAAwB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { base64, base64urlnopad, utf8 } from '@scure/base';
|
|
2
|
+
export const createEnvelopeUtils = () => {
|
|
3
|
+
const wrap = (object) => base64.encode(utf8.decode(JSON.stringify(object)));
|
|
4
|
+
const tokenize = (object) => base64urlnopad.encode(utf8.decode(JSON.stringify(object)));
|
|
5
|
+
const untokenize = (token) => JSON.parse(utf8.encode(base64urlnopad.decode(token)));
|
|
6
|
+
const unwrap = (envelope) => JSON.parse(utf8.encode(base64.decode(envelope)));
|
|
7
|
+
return { wrap, tokenize, untokenize, unwrap };
|
|
8
|
+
};
|
|
9
|
+
export const envelopeUtils = createEnvelopeUtils();
|
|
10
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/utils/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAI1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAkB,EAAE;IACrD,MAAM,IAAI,GAAG,CAAC,MAAgB,EAAU,EAAE,CACxC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAEpD,MAAM,QAAQ,GAAG,CAAC,MAAgB,EAAU,EAAE,CAC5C,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAE5D,MAAM,UAAU,GAAG,CAAC,KAAa,EAAY,EAAE,CAC7C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAEvD,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAY,EAAE,CAC5C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAElD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;AAC/C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAA"}
|
package/build/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './envelope.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAA"}
|
package/build/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './envelope.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/build/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAA"}
|
package/build/utils/model.d.ts
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import type { Envelope } from '../types.js';
|
|
2
|
-
declare const wrap: (object: Envelope) => string;
|
|
3
|
-
declare const tokenize: (object: Envelope) => string;
|
|
4
|
-
declare const untokenize: (token: string) => Envelope;
|
|
5
|
-
declare const unwrap: (envelope: string) => Envelope;
|
|
6
|
-
export declare const createUtilsModelHelper: () => {
|
|
7
|
-
wrap: typeof wrap;
|
|
8
|
-
tokenize: typeof tokenize;
|
|
9
|
-
untokenize: typeof untokenize;
|
|
10
|
-
unwrap: typeof unwrap;
|
|
11
|
-
};
|
|
12
|
-
export declare const utilsModelHelper: {
|
|
13
|
-
wrap: typeof wrap;
|
|
14
|
-
tokenize: typeof tokenize;
|
|
15
|
-
untokenize: typeof untokenize;
|
|
16
|
-
unwrap: typeof unwrap;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
2
|
+
export declare const wrap: (object: Envelope) => string;
|
|
3
|
+
export declare const tokenize: (object: Envelope) => string;
|
|
4
|
+
export declare const untokenize: (token: string) => Envelope;
|
|
5
|
+
export declare const unwrap: (envelope: string) => Envelope;
|
|
19
6
|
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/utils/model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/utils/model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,eAAO,MAAM,IAAI,WAAY,QAAQ,KAAG,MACY,CAAA;AAEpD,eAAO,MAAM,QAAQ,WAAY,QAAQ,KAAG,MACgB,CAAA;AAE5D,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,QACY,CAAA;AAEvD,eAAO,MAAM,MAAM,aAAc,MAAM,KAAG,QACQ,CAAA"}
|
package/build/utils/model.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { base64, base64urlnopad, utf8 } from '@scure/base';
|
|
2
|
-
const wrap = (object) => base64.encode(utf8.decode(JSON.stringify(object)));
|
|
3
|
-
const tokenize = (object) => base64urlnopad.encode(utf8.decode(JSON.stringify(object)));
|
|
4
|
-
const untokenize = (token) => JSON.parse(utf8.encode(base64urlnopad.decode(token)));
|
|
5
|
-
const unwrap = (envelope) => JSON.parse(utf8.encode(base64.decode(envelope)));
|
|
6
|
-
export const createUtilsModelHelper = () => ({ wrap, tokenize, untokenize, unwrap });
|
|
7
|
-
export const utilsModelHelper = createUtilsModelHelper();
|
|
2
|
+
export const wrap = (object) => base64.encode(utf8.decode(JSON.stringify(object)));
|
|
3
|
+
export const tokenize = (object) => base64urlnopad.encode(utf8.decode(JSON.stringify(object)));
|
|
4
|
+
export const untokenize = (token) => JSON.parse(utf8.encode(base64urlnopad.decode(token)));
|
|
5
|
+
export const unwrap = (envelope) => JSON.parse(utf8.encode(base64.decode(envelope)));
|
|
8
6
|
//# sourceMappingURL=model.js.map
|
package/build/utils/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/utils/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAG1D,MAAM,IAAI,GAAG,CAAC,MAAgB,EAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/utils/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAG1D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,MAAgB,EAAU,EAAE,CAC/C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAEpD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAgB,EAAU,EAAE,CACnD,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAE5D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAY,EAAE,CACpD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAEvD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAY,EAAE,CACnD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/basic-envelope",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.47",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@owlmeans/dep-config": "workspace:*",
|
|
26
|
-
"@owlmeans/test-auth": "^0.1.18-rc.
|
|
26
|
+
"@owlmeans/test-auth": "^0.1.18-rc.47",
|
|
27
27
|
"@types/bun": "^1.4.2",
|
|
28
28
|
"nodemon": "^3.1.14",
|
|
29
29
|
"typescript": "^7.0.2"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@noble/curves": "^2.4.0",
|
|
33
33
|
"@noble/hashes": "^2.4.0",
|
|
34
|
-
"@owlmeans/basic-keys": "^0.1.18-rc.
|
|
34
|
+
"@owlmeans/basic-keys": "^0.1.18-rc.49",
|
|
35
35
|
"@scure/base": "^2.4.0"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
package/src/model.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { base64, utf8 } from '@scure/base'
|
|
2
2
|
import { DEFAULT_TTL, EnvelopeKind } from './consts.js'
|
|
3
3
|
import type { EnvelopeModel } from './types.js'
|
|
4
|
-
import {
|
|
4
|
+
import { envelopeUtils } from './utils/envelope.js'
|
|
5
5
|
|
|
6
6
|
export const makeEnvelopeModel = <T extends {} | string = string>(
|
|
7
7
|
type: string, kind?: EnvelopeKind
|
|
@@ -13,7 +13,7 @@ export const makeEnvelopeModel = <T extends {} | string = string>(
|
|
|
13
13
|
dt: new Date().getTime(),
|
|
14
14
|
ttl: DEFAULT_TTL
|
|
15
15
|
} : kind === EnvelopeKind.Wrap
|
|
16
|
-
?
|
|
16
|
+
? envelopeUtils.unwrap(type) : envelopeUtils.untokenize(type),
|
|
17
17
|
|
|
18
18
|
send: (msg, ttl) => {
|
|
19
19
|
model.envelope.msg = typeof msg == 'string' ? msg : base64.encode(utf8.decode(JSON.stringify(msg)))
|
|
@@ -37,9 +37,9 @@ export const makeEnvelopeModel = <T extends {} | string = string>(
|
|
|
37
37
|
|
|
38
38
|
type: () => model.envelope.t,
|
|
39
39
|
|
|
40
|
-
wrap: () =>
|
|
40
|
+
wrap: () => envelopeUtils.wrap(model.envelope),
|
|
41
41
|
|
|
42
|
-
tokenize: () =>
|
|
42
|
+
tokenize: () => envelopeUtils.tokenize(model.envelope),
|
|
43
43
|
|
|
44
44
|
sign: async (key, kind) => {
|
|
45
45
|
model.envelope.sig = await key.sign(model.envelope)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Envelope } from '../../types.js'
|
|
2
|
+
|
|
3
|
+
/** The two serialized forms of an envelope: wrapped (base64) and tokenized (base64url). */
|
|
4
|
+
export interface EnvelopeUtils {
|
|
5
|
+
wrap: (object: Envelope) => string
|
|
6
|
+
tokenize: (object: Envelope) => string
|
|
7
|
+
untokenize: (token: string) => Envelope
|
|
8
|
+
unwrap: (envelope: string) => Envelope
|
|
9
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { base64, base64urlnopad, utf8 } from '@scure/base'
|
|
2
|
+
import type { Envelope } from '../types.js'
|
|
3
|
+
import type { EnvelopeUtils } from './envelope/types.js'
|
|
4
|
+
|
|
5
|
+
export const createEnvelopeUtils = (): EnvelopeUtils => {
|
|
6
|
+
const wrap = (object: Envelope): string =>
|
|
7
|
+
base64.encode(utf8.decode(JSON.stringify(object)))
|
|
8
|
+
|
|
9
|
+
const tokenize = (object: Envelope): string =>
|
|
10
|
+
base64urlnopad.encode(utf8.decode(JSON.stringify(object)))
|
|
11
|
+
|
|
12
|
+
const untokenize = (token: string): Envelope =>
|
|
13
|
+
JSON.parse(utf8.encode(base64urlnopad.decode(token)))
|
|
14
|
+
|
|
15
|
+
const unwrap = (envelope: string): Envelope =>
|
|
16
|
+
JSON.parse(utf8.encode(base64.decode(envelope)))
|
|
17
|
+
|
|
18
|
+
return { wrap, tokenize, untokenize, unwrap }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const envelopeUtils = createEnvelopeUtils()
|
package/src/utils/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './envelope.js'
|
package/build/utils/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAA"}
|
package/src/utils/model.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { base64, base64urlnopad, utf8 } from '@scure/base'
|
|
2
|
-
import type { Envelope } from '../types.js'
|
|
3
|
-
|
|
4
|
-
const wrap = (object: Envelope): string =>
|
|
5
|
-
base64.encode(utf8.decode(JSON.stringify(object)))
|
|
6
|
-
|
|
7
|
-
const tokenize = (object: Envelope): string =>
|
|
8
|
-
base64urlnopad.encode(utf8.decode(JSON.stringify(object)))
|
|
9
|
-
|
|
10
|
-
const untokenize = (token: string): Envelope =>
|
|
11
|
-
JSON.parse(utf8.encode(base64urlnopad.decode(token)))
|
|
12
|
-
|
|
13
|
-
const unwrap = (envelope: string): Envelope =>
|
|
14
|
-
JSON.parse(utf8.encode(base64.decode(envelope)))
|
|
15
|
-
|
|
16
|
-
export const createUtilsModelHelper = () => ({ wrap, tokenize, untokenize, unwrap })
|
|
17
|
-
|
|
18
|
-
export const utilsModelHelper = createUtilsModelHelper()
|
package/src/utils/types.ts
DELETED
|
File without changes
|