@me2em/core 0.4.1-alpha.1

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/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export { Identity } from './identity.js';
2
+ export { Handle, type HandleMetadata } from './handle.js';
3
+ export { Session, type SessionOptions, type SessionToken } from './session.js';
4
+ export * as crypto from './crypto/index.js';
5
+
6
+ export const PROTOCOL_VERSION = '0.1.0-alpha.1';
package/src/session.ts ADDED
@@ -0,0 +1,25 @@
1
+ export interface SessionOptions {
2
+ audience: string;
3
+ scopes: string[];
4
+ ttl?: number; // в секундах
5
+ }
6
+
7
+ export interface SessionToken {
8
+ handleId: string;
9
+ scopes: string[];
10
+ expiresAt: number;
11
+ token: string;
12
+ }
13
+
14
+ export class Session {
15
+ constructor(
16
+ public readonly handleId: string,
17
+ public readonly scopes: string[],
18
+ public readonly expiresAt: number,
19
+ public readonly token: string
20
+ ) {}
21
+
22
+ isExpired(): boolean {
23
+ return Date.now() >= this.expiresAt * 1000;
24
+ }
25
+ }