@vibes.diy/identity 2.6.1 → 2.6.3

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/LICENSE.md CHANGED
@@ -1,32 +1,3 @@
1
- The contents of this repository are Copyright (c) corresponding authors and
2
- contributors, licensed under the `Permissive License Stack` meaning either of:
3
-
4
- - Apache-2.0 Software License: https://www.apache.org/licenses/LICENSE-2.0
5
- ([...4tr2kfsq](https://dweb.link/ipfs/bafkreiankqxazcae4onkp436wag2lj3ccso4nawxqkkfckd6cg4tr2kfsq))
6
-
7
- - MIT Software License: https://opensource.org/licenses/MIT
8
- ([...vljevcba](https://dweb.link/ipfs/bafkreiepofszg4gfe2gzuhojmksgemsub2h4uy2gewdnr35kswvljevcba))
9
-
10
- You may not use the contents of this repository except in compliance
11
- with one of the listed Licenses. For an extended clarification of the
12
- intent behind the choice of Licensing please refer to
13
- https://protocol.ai/blog/announcing-the-permissive-license-stack/
14
-
15
- Unless required by applicable law or agreed to in writing, software
16
- distributed under the terms listed in this notice is distributed on
17
- an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
18
- either express or implied. See each License for the specific language
19
- governing permissions and limitations under that License.
20
-
21
- <!--- SPDX-License-Identifier: Apache-2.0 OR MIT -->
22
-
23
- `SPDX-License-Identifier: Apache-2.0 OR MIT`
24
-
25
- Verbatim copies of both licenses are included below:
26
-
27
- <details><summary>Apache-2.0 Software License</summary>
28
-
29
- ```
30
1
  Apache License
31
2
  Version 2.0, January 2004
32
3
  http://www.apache.org/licenses/
@@ -203,30 +174,28 @@ Verbatim copies of both licenses are included below:
203
174
  of your accepting any such warranty or additional liability.
204
175
 
205
176
  END OF TERMS AND CONDITIONS
206
- ```
207
177
 
208
- </details>
178
+ APPENDIX: How to apply the Apache License to your work.
209
179
 
210
- <details><summary>MIT Software License</summary>
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
211
188
 
212
- ```
213
- Permission is hereby granted, free of charge, to any person obtaining a copy
214
- of this software and associated documentation files (the "Software"), to deal
215
- in the Software without restriction, including without limitation the rights
216
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
217
- copies of the Software, and to permit persons to whom the Software is
218
- furnished to do so, subject to the following conditions:
189
+ Copyright [yyyy] [name of copyright owner]
219
190
 
220
- The above copyright notice and this permission notice shall be included in
221
- all copies or substantial portions of the Software.
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
222
194
 
223
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
224
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
225
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
226
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
227
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
228
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
229
- THE SOFTWARE.
230
- ```
195
+ http://www.apache.org/licenses/LICENSE-2.0
231
196
 
232
- </details>
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,23 +1,38 @@
1
1
  [![Join our
2
- Discord](https://discord-badge.selem.workers.dev/i/weSgWt684k.svg)](https://discord.gg/weSgWt684k)
2
+ Discord](https://discord-badge.selem.workers.dev/i/vnpWycj4Ta.svg)](https://discord.gg/vnpWycj4Ta)
3
3
 
4
- # ✨ Build Mini Apps with AI Magic
4
+ # ✨ Vibes DIY — make apps with your friends
5
5
 
6
- Turn your **ideas** into **interactive apps** instantly. [Try it now](https://vibes.diy/) or [fork on GitHub](https://github.com/VibesDIY/vibes.diy) to customize with your own AI account.
6
+ Software is getting weird again. Describe what you want and get a real, live app — fun, done, and alive. [Try it now](https://vibes.diy/) or [fork on GitHub](https://github.com/VibesDIY/vibes.diy).
7
7
 
8
- Create beautiful, interactive mini apps with zero setup. Your creations are automatically saved and can be shared instantly.
8
+ Make apps with your friends, so easy even AI can do it. Describe your app in plain words, it builds instantly, and you keep changing it just by talking to it. Share the link and your friends join right away — no setup, no "wait, let me send you the invite."
9
9
 
10
- ## Features
10
+ ## Why it's different
11
11
 
12
- - Create interactive mini apps using AI
13
- - Browse and return to your previous creations
14
- - Auto-save your work securely
15
- - See your app changes in real-time
12
+ - **Fun** — build for any reason, or no reason at all.
13
+ - **Done** — it's a real app at its own live link, not a prototype. State is saved automatically.
14
+ - **Alive** — keep talking to it and it keeps changing. So can anyone you share it with.
15
+
16
+ Seeing a vibe makes you want to change it. Start from someone else's, tweak it to fit you, share it, and the people you share with remix their own version. You're not a user anymore — you're a maker.
17
+
18
+ ## What people make
19
+
20
+ A character bot that answers in your voice. A neighborhood resource tracker you share at the next town meeting. A flashcard app remixed into collaborative trivia your students change live. A workout tracker a whole gym swaps routines on. Every one is the same move: start, tweak, share, remix.
21
+
22
+ ## Yours to control
23
+
24
+ Private by default — or open to the world. You choose. Keep an app to the people you invite, or publish it so anyone can use and remix it. You set who can read, write, and open it.
25
+
26
+ > Your app's data lives in a centralized cloud database. "Private" means access-gated from other people — not encrypted, and not hidden from the platform.
27
+
28
+ ## Open source
29
+
30
+ The whole platform is open source under Apache 2.0. Read the code, open an issue, send a PR.
16
31
 
17
32
  ## Quick Start
18
33
 
19
- 1. [Try the demo](https://vibes.diy/) - No setup required!
20
- 2. Or set up your own:
34
+ 1. [Try the demo](https://vibes.diy/) — no setup required.
35
+ 2. Or run it yourself:
21
36
  - Clone the repository
22
37
  - Install with `pnpm i`
23
38
  - Run `pnpm dev`
@@ -28,11 +43,4 @@ We are committed to providing a welcoming and inclusive environment for all cont
28
43
 
29
44
  Interested in contributing? Check out our [Contributing Guide](CONTRIBUTING.md) to get started.
30
45
 
31
- ## Your Work is Always Safe
32
-
33
- Every app you create is automatically saved, so you can:
34
-
35
- - Browse your creations in the sidebar
36
- - Return to previous work anytime
37
- - Keep track of your building history
38
- - Save screenshots of your apps
46
+ Find us on [Discord](https://discord.gg/vnpWycj4Ta), [Substack](https://vibesdiy.substack.com/), [YouTube](https://www.youtube.com/@VibesDIY), and [Bluesky](https://bsky.app/profile/vibes.diy).
@@ -0,0 +1,14 @@
1
+ import type { BaseXXEndeCoder, CertificatePayload } from "@fireproof/core-types-base";
2
+ import type { CertorIf } from "@fireproof/core-types-device-id";
3
+ export declare class Certor implements CertorIf {
4
+ #private;
5
+ readonly base64: BaseXXEndeCoder;
6
+ static fromString(base64: BaseXXEndeCoder, cert: string): Certor;
7
+ static fromUnverifiedJWT(base64: BaseXXEndeCoder, jwtString: string): Certor;
8
+ constructor(base64: BaseXXEndeCoder, cert: CertificatePayload);
9
+ asCert(): CertificatePayload;
10
+ parseCertificateSubject(s: string): Record<string, string>;
11
+ asSHA1(): Promise<string>;
12
+ asSHA256(): Promise<string>;
13
+ asBase64(): string;
14
+ }
@@ -0,0 +1,54 @@
1
+ import { toSortedObject } from "@adviser/cement";
2
+ import { CertificatePayloadSchema } from "@fireproof/core-types-base";
3
+ import { decodeJwt } from "jose";
4
+ import { base58btc } from "multiformats/bases/base58";
5
+ import { sha1 } from "multiformats/hashes/sha1";
6
+ import { sha256 } from "multiformats/hashes/sha2";
7
+ import { deepFreeze } from "@fireproof/core-runtime";
8
+ export class Certor {
9
+ #cert;
10
+ base64;
11
+ #strCert;
12
+ #uint8Cert;
13
+ static fromString(base64, cert) {
14
+ const certObj = CertificatePayloadSchema.parse(JSON.parse(base64.decode(cert)));
15
+ return new Certor(base64, certObj);
16
+ }
17
+ static fromUnverifiedJWT(base64, jwtString) {
18
+ const payload = decodeJwt(jwtString);
19
+ const certObj = CertificatePayloadSchema.parse(payload);
20
+ return new Certor(base64, certObj);
21
+ }
22
+ constructor(base64, cert) {
23
+ this.#cert = deepFreeze(toSortedObject(cert));
24
+ this.base64 = base64;
25
+ }
26
+ asCert() {
27
+ return this.#cert;
28
+ }
29
+ parseCertificateSubject(s) {
30
+ const parts = {};
31
+ s.split(",").forEach((part) => {
32
+ const [key, value] = part.trim().split("=");
33
+ if (key && value) {
34
+ parts[key] = value;
35
+ }
36
+ });
37
+ return parts;
38
+ }
39
+ async asSHA1() {
40
+ this.#uint8Cert ||= this.base64.decodeUint8(this.asBase64());
41
+ const val = await sha1.digest(this.#uint8Cert);
42
+ return base58btc.encode(val.bytes);
43
+ }
44
+ async asSHA256() {
45
+ this.#uint8Cert ||= this.base64.decodeUint8(this.asBase64());
46
+ const val = await sha256.digest(this.#uint8Cert);
47
+ return base58btc.encode(val.bytes);
48
+ }
49
+ asBase64() {
50
+ this.#strCert ||= this.base64.encode(JSON.stringify(toSortedObject(this.#cert)));
51
+ return this.#strCert;
52
+ }
53
+ }
54
+ //# sourceMappingURL=certor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certor.js","sourceRoot":"","sources":["../../jsr/device-id/certor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B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rB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC7D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/C,OAAO,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC7D,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACjD,OAAO,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjF,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import type { Subject, Extensions, FPDeviceIDCSRPayload, SuperThis } from "@fireproof/core-types-base";
2
+ import { Result } from "@adviser/cement";
3
+ import { DeviceIdKey } from "./key.js";
4
+ export declare class DeviceIdCSR {
5
+ #private;
6
+ constructor(sthis: SuperThis, key: DeviceIdKey);
7
+ createCSRPayload(subject: Subject, extensions?: Partial<Extensions>): Promise<FPDeviceIDCSRPayload>;
8
+ signCSR(payload: FPDeviceIDCSRPayload): Promise<Result<string>>;
9
+ createCSR(subject: Subject, extensions?: Partial<Extensions>): Promise<Result<string, Error>>;
10
+ }
@@ -0,0 +1,52 @@
1
+ import { calculateJwkThumbprint, SignJWT } from "jose";
2
+ import { FPDeviceIDCSRPayloadSchema } from "@fireproof/core-types-base";
3
+ import { exception2Result } from "@adviser/cement";
4
+ export class DeviceIdCSR {
5
+ #key;
6
+ #sthis;
7
+ constructor(sthis, key) {
8
+ this.#key = key;
9
+ this.#sthis = sthis;
10
+ }
11
+ async createCSRPayload(subject, extensions = {}) {
12
+ const now = Math.floor(Date.now() / 1000);
13
+ return FPDeviceIDCSRPayloadSchema.parse({
14
+ sub: subject.commonName,
15
+ iss: "csr-client",
16
+ aud: "certificate-authority",
17
+ iat: now,
18
+ exp: now + 3600,
19
+ jti: this.#sthis.nextId(16).str,
20
+ csr: {
21
+ subject: subject,
22
+ publicKey: await this.#key.publicKey(),
23
+ extensions: {
24
+ subjectAltName: extensions.subjectAltName || [],
25
+ keyUsage: extensions.keyUsage || ["digitalSignature", "keyEncipherment"],
26
+ extendedKeyUsage: extensions.extendedKeyUsage || ["serverAuth"],
27
+ },
28
+ },
29
+ });
30
+ }
31
+ async signCSR(payload) {
32
+ return exception2Result(async () => {
33
+ const publicJWK = await this.#key.publicKey();
34
+ const jws = await new SignJWT(payload)
35
+ .setProtectedHeader({
36
+ alg: "ES256",
37
+ typ: "CSR+JWT",
38
+ jwk: publicJWK,
39
+ kid: await calculateJwkThumbprint(publicJWK, "sha256"),
40
+ })
41
+ .setIssuedAt()
42
+ .setExpirationTime("1h")
43
+ .sign(await this.#key.exportPrivateJWK());
44
+ return jws;
45
+ });
46
+ }
47
+ async createCSR(subject, extensions = {}) {
48
+ const payload = await this.createCSRPayload(subject, extensions);
49
+ return this.signCSR(payload);
50
+ }
51
+ }
52
+ //# sourceMappingURL=csr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csr.js","sourceRoot":"","sources":["../../jsr/device-id/csr.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAqC,MAAM,MAAM,CAAC;A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C;YAC9C,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,OAAyB,CAAC;iBACrD,kBAAkB,CAAC;gBAClB,GAAG,EAAE,OAAO;gBACZ,GAAG,EAAE,SAAS;gBACd,GAAG,EAAE,SAAS;gBACd,GAAG,EAAE,MAAM,sBAAsB,CAAC,SAAS,EAAE,QAAQ,CAAC;aACvD,CAAC;iBACD,WAAW,EAAE;iBACb,iBAAiB,CAAC,IAAI,CAAC;iBACvB,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;YAC5C,OAAO,GAAG,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAgB,EAAE,UAAU,GAAwB,EAAE;QACpE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import { Result } from "@adviser/cement";
2
+ import type { JWKPrivate, JWKPublic } from "@fireproof/core-types-base";
3
+ import type { DeviceIdKeyIf } from "@fireproof/core-types-device-id";
4
+ import { type GenerateKeyPairOptions } from "jose";
5
+ export declare class DeviceIdKey implements DeviceIdKeyIf {
6
+ #private;
7
+ static create(opts?: GenerateKeyPairOptions): Promise<DeviceIdKey>;
8
+ static createFromJWK(jwk: JWKPrivate, opts?: GenerateKeyPairOptions): Promise<Result<DeviceIdKey>>;
9
+ private constructor();
10
+ fingerPrint(): Promise<string>;
11
+ exportPrivateJWK(): Promise<JWKPrivate>;
12
+ publicKey(): Promise<JWKPublic>;
13
+ }
@@ -0,0 +1,46 @@
1
+ import { Result } from "@adviser/cement";
2
+ import { JWKPrivateSchema, JWKPublicSchema } from "@fireproof/core-types-base";
3
+ import { generateKeyPair, exportJWK, calculateJwkThumbprint } from "jose";
4
+ import { sts } from "@fireproof/core-runtime";
5
+ export class DeviceIdKey {
6
+ #privateKey;
7
+ static async create(opts = { extractable: true }) {
8
+ const pair = await generateKeyPair("ES256", opts);
9
+ return new DeviceIdKey(pair.privateKey);
10
+ }
11
+ static async createFromJWK(jwk, opts = { extractable: true }) {
12
+ const parsed = JWKPrivateSchema.safeParse(jwk);
13
+ if (!parsed.success) {
14
+ return Result.Err(`Invalid JWK: ${parsed.error.message}`);
15
+ }
16
+ const j = parsed.data;
17
+ const rKey = await sts.importJWK(j, undefined, opts);
18
+ if (rKey.isErr()) {
19
+ return Result.Err(rKey);
20
+ }
21
+ return Result.Ok(new DeviceIdKey(rKey.Ok().key));
22
+ }
23
+ constructor(pair) {
24
+ this.#privateKey = pair;
25
+ }
26
+ async fingerPrint() {
27
+ return calculateJwkThumbprint(await this.exportPrivateJWK(), "sha256");
28
+ }
29
+ async exportPrivateJWK() {
30
+ const jwk = await exportJWK(this.#privateKey);
31
+ const { success, data } = JWKPrivateSchema.safeParse(jwk);
32
+ if (!success || !data) {
33
+ throw new Error("Invalid JWK");
34
+ }
35
+ return data;
36
+ }
37
+ async publicKey() {
38
+ const privateJWK = await exportJWK(this.#privateKey);
39
+ const { success, data, error } = JWKPublicSchema.safeParse(privateJWK);
40
+ if (!success || !data) {
41
+ throw new Error(`Invalid public JWK: ${error.message}`);
42
+ }
43
+ return data;
44
+ }
45
+ }
46
+ //# sourceMappingURL=key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.js","sourceRoot":"","sources":["../../jsr/device-id/key.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,sBAAsB,EAA+B,MAAM,MAAM,CAAC;AACvG,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAE9C,MAAM,OAAO,W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AAC,CAAC;QAC9C,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACrD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,eAAe,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QACvE,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,uBAAuB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { BaseXXEndeCoder, CertificatePayload, JWTPayload } from "@fireproof/core-types-base";
2
+ import { DeviceIdKey } from "./key.js";
3
+ export declare class DeviceIdSignMsg {
4
+ #private;
5
+ readonly base64: BaseXXEndeCoder;
6
+ constructor(base64: BaseXXEndeCoder, key: DeviceIdKey, cert: CertificatePayload);
7
+ sign<T extends JWTPayload>(payload: T, algorithm?: string): Promise<string>;
8
+ }
@@ -0,0 +1,31 @@
1
+ import { calculateJwkThumbprint, SignJWT } from "jose";
2
+ import { Certor } from "./certor.js";
3
+ export class DeviceIdSignMsg {
4
+ #key;
5
+ #cert;
6
+ base64;
7
+ constructor(base64, key, cert) {
8
+ this.#key = key;
9
+ this.#cert = cert;
10
+ this.base64 = base64;
11
+ }
12
+ async sign(payload, algorithm = "ES256") {
13
+ const certor = new Certor(this.base64, this.#cert);
14
+ const x5c = [certor.asBase64()];
15
+ const x5t = await certor.asSHA1();
16
+ const x5tS256 = await certor.asSHA256();
17
+ return await new SignJWT(payload)
18
+ .setProtectedHeader({
19
+ alg: algorithm,
20
+ typ: "JWT",
21
+ kid: await calculateJwkThumbprint(await this.#key.publicKey(), "sha256"),
22
+ x5c: x5c,
23
+ x5t: x5t,
24
+ "x5t#S256": x5tS256,
25
+ })
26
+ .setIssuedAt()
27
+ .setExpirationTime("1h")
28
+ .sign(await this.#key.exportPrivateJWK());
29
+ }
30
+ }
31
+ //# sourceMappingURL=sign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign.js","sourceRoot":"","sources":["../../jsr/device-id/sign.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAqC,MAAM,MAAM,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,MAAM,OAAO,eAAe;IACjB,IAAI,CAAc;IAClB,KAAK,CAAqB;IAC1B,MAAM,CAAkB;IAEjC,YAAY,MAAuB,EAAE,GAAgB,EAAE,IAAwB;QAC7E,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,IAAI,CAAuB,OAAU,EAAE,SAAS,GAAG,OAAO;QAC9D,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxC,OAAO,MAAM,IAAI,OAAO,CAAC,OAAyB,CAAC;aAChD,kBAAkB,CAAC;YAClB,GAAG,EAAE,SAAS;YACd,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,MAAM,sBAAsB,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,QAAQ,CAAC;YACxE,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,GAAG;YACR,UAAU,EAAE,OAAO;SACpB,CAAC;aACD,WAAW,EAAE;aACb,iBAAiB,CAAC,IAAI,CAAC;aACvB,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC9C,CAAC;CACF"}
package/node.d.ts CHANGED
@@ -2,7 +2,10 @@ import { Result } from "@adviser/cement";
2
2
  import type { SuperThis } from "@fireproof/core-types-base";
3
3
  import type { DashAuthType } from "@fireproof/core-types-protocols-dashboard";
4
4
  export { getKeyBag } from "@fireproof/core-keybag";
5
- export { DeviceIdKey, DeviceIdSignMsg, DeviceIdCSR, DeviceIdCA } from "@fireproof/core-device-id";
5
+ export { DeviceIdKey } from "./device-id/key.js";
6
+ export { DeviceIdSignMsg } from "./device-id/sign.js";
7
+ export { DeviceIdCSR } from "./device-id/csr.js";
8
+ export { DeviceIdCA } from "@fireproof/core-device-id";
6
9
  export { deviceIdRegisterEvento, isResDeviceIdRegister } from "@fireproof/core-cli";
7
10
  export type { ReqDeviceIdRegister } from "@fireproof/core-cli";
8
11
  export declare function createDeviceIdGetToken(sthis: SuperThis, opts: {
package/node.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import { Lazy, Result } from "@adviser/cement";
2
2
  import { getKeyBag } from "@fireproof/core-keybag";
3
- import { DeviceIdKey, DeviceIdSignMsg } from "@fireproof/core-device-id";
3
+ import { DeviceIdKey } from "./device-id/key.js";
4
+ import { DeviceIdSignMsg } from "./device-id/sign.js";
4
5
  export { getKeyBag } from "@fireproof/core-keybag";
5
- export { DeviceIdKey, DeviceIdSignMsg, DeviceIdCSR, DeviceIdCA } from "@fireproof/core-device-id";
6
+ export { DeviceIdKey } from "./device-id/key.js";
7
+ export { DeviceIdSignMsg } from "./device-id/sign.js";
8
+ export { DeviceIdCSR } from "./device-id/csr.js";
9
+ export { DeviceIdCA } from "@fireproof/core-device-id";
6
10
  export { deviceIdRegisterEvento, isResDeviceIdRegister } from "@fireproof/core-cli";
7
11
  export async function createDeviceIdGetToken(sthis, opts) {
8
12
  const kb = await getKeyBag(sthis);
package/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../jsr/node.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAMzE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIlG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAiBpF,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,KAAgB,EAChB,IAAoE;IAEpE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,kBAAkB,IAAI,uDAAuD,CAAC,CAAC;IACtG,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACzE,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;QACpB,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,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AI,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,CAC7B;YACE,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,GAAG,EAAE,WAAW;YAChB,QAAQ,EAAE,MAAM,OAAO,CAAC,EAAE,EAAE,CAAC,WAAW,EAAE;YAC1C,GAAG,EAAE,EAAE,GAAG;YACV,GAAG,EAAE,GAAG,GAAG,GAAG;YACd,GAAG,EAAE,GAAG,GAAG,CAAC;YACZ,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG;SACI,EAC7B,OAAO,CACR,CAAC;QACF,OAAO,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;IACjD,CAAC,EACD,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CACpC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibes.diy/identity",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "exports": {
@@ -22,6 +22,8 @@
22
22
  "@fireproof/core-types-base": "~0.24.19",
23
23
  "@fireproof/core-types-device-id": "~0.24.19",
24
24
  "@fireproof/core-types-protocols-dashboard": "~0.24.19",
25
+ "jose": "~6.2.2",
26
+ "multiformats": "~13.4.2",
25
27
  "zod": "~4.4.3"
26
28
  },
27
29
  "repository": {