@sprucelabs/heartwood-view-controllers 116.0.40 → 117.0.0
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/build/auth/Authenticator.d.ts +5 -17
- package/build/auth/Authenticator.js +15 -10
- package/build/esm/auth/Authenticator.d.ts +5 -17
- package/build/esm/auth/Authenticator.js +32 -16
- package/build/esm/types/heartwood.types.d.ts +85 -17
- package/build/esm/types/heartwood.types.js +44 -0
- package/build/types/heartwood.types.d.ts +85 -17
- package/build/types/heartwood.types.js +45 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MercuryEventEmitter } from '@sprucelabs/mercury-types';
|
|
2
2
|
import { Person } from '@sprucelabs/spruce-core-schemas';
|
|
3
|
-
import {
|
|
3
|
+
import { AuthContract, Authenticator, Storage } from '../types/heartwood.types';
|
|
4
4
|
export default class AuthenticatorImpl implements Authenticator {
|
|
5
5
|
static Class?: new (storage: Storage) => Authenticator;
|
|
6
6
|
private static instance;
|
|
7
7
|
private static storage;
|
|
8
|
-
protected
|
|
8
|
+
protected emitter: MercuryEventEmitter<AuthContract>;
|
|
9
9
|
protected storage: Storage;
|
|
10
10
|
protected constructor(storage: Storage);
|
|
11
11
|
static getInstance(): Authenticator;
|
|
@@ -15,18 +15,6 @@ export default class AuthenticatorImpl implements Authenticator {
|
|
|
15
15
|
getSessionToken(): string | null;
|
|
16
16
|
getPerson(): any;
|
|
17
17
|
isLoggedIn(): boolean;
|
|
18
|
-
clearSession(): void
|
|
19
|
-
addEventListener<
|
|
20
|
-
}
|
|
21
|
-
export interface AuthenticatorEmitterMap {
|
|
22
|
-
'did-login': {
|
|
23
|
-
token: string;
|
|
24
|
-
person: Person;
|
|
25
|
-
}[];
|
|
26
|
-
'will-logout': {
|
|
27
|
-
person: Person;
|
|
28
|
-
}[];
|
|
29
|
-
'did-logout': {
|
|
30
|
-
person: Person;
|
|
31
|
-
}[];
|
|
18
|
+
clearSession(): Promise<void>;
|
|
19
|
+
addEventListener: MercuryEventEmitter<AuthContract>['on'];
|
|
32
20
|
}
|
|
@@ -3,11 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const mercury_event_emitter_1 = require("@sprucelabs/mercury-event-emitter");
|
|
7
7
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
8
|
+
const heartwood_types_1 = require("../types/heartwood.types");
|
|
8
9
|
class AuthenticatorImpl {
|
|
9
10
|
constructor(storage) {
|
|
10
|
-
this.
|
|
11
|
+
this.addEventListener = async (name, cb) => {
|
|
12
|
+
await this.emitter.on(name, cb);
|
|
13
|
+
};
|
|
14
|
+
this.emitter = new AuthEmitter();
|
|
11
15
|
this.storage = storage;
|
|
12
16
|
}
|
|
13
17
|
static getInstance() {
|
|
@@ -29,7 +33,7 @@ class AuthenticatorImpl {
|
|
|
29
33
|
setSessionToken(token, person) {
|
|
30
34
|
this.storage.setItem('sessionToken', token);
|
|
31
35
|
this.storage.setItem('person', JSON.stringify(person));
|
|
32
|
-
this.
|
|
36
|
+
void this.emitter.emit('did-login', { token, person });
|
|
33
37
|
}
|
|
34
38
|
getSessionToken() {
|
|
35
39
|
return this.storage.getItem('sessionToken') ?? null;
|
|
@@ -41,19 +45,20 @@ class AuthenticatorImpl {
|
|
|
41
45
|
isLoggedIn() {
|
|
42
46
|
return !!this.getSessionToken();
|
|
43
47
|
}
|
|
44
|
-
clearSession() {
|
|
48
|
+
async clearSession() {
|
|
45
49
|
if (!this.isLoggedIn()) {
|
|
46
50
|
return;
|
|
47
51
|
}
|
|
48
52
|
const person = JSON.parse(this.storage.getItem('person') ?? '{}');
|
|
49
|
-
this.
|
|
53
|
+
await this.emitter.emit('will-logout', { person });
|
|
50
54
|
this.storage.removeItem('sessionToken');
|
|
51
55
|
this.storage.removeItem('person');
|
|
52
|
-
this.
|
|
53
|
-
}
|
|
54
|
-
addEventListener(name, cb) {
|
|
55
|
-
//@ts-ignore
|
|
56
|
-
this.eventEmitter.addListener(name, cb);
|
|
56
|
+
await this.emitter.emit('did-logout', { person });
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
exports.default = AuthenticatorImpl;
|
|
60
|
+
class AuthEmitter extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(heartwood_types_1.authContract);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MercuryEventEmitter } from '@sprucelabs/mercury-types';
|
|
2
2
|
import { Person } from '@sprucelabs/spruce-core-schemas';
|
|
3
|
-
import {
|
|
3
|
+
import { AuthContract, Authenticator, Storage } from '../types/heartwood.types';
|
|
4
4
|
export default class AuthenticatorImpl implements Authenticator {
|
|
5
5
|
static Class?: new (storage: Storage) => Authenticator;
|
|
6
6
|
private static instance;
|
|
7
7
|
private static storage;
|
|
8
|
-
protected
|
|
8
|
+
protected emitter: MercuryEventEmitter<AuthContract>;
|
|
9
9
|
protected storage: Storage;
|
|
10
10
|
protected constructor(storage: Storage);
|
|
11
11
|
static getInstance(): Authenticator;
|
|
@@ -15,18 +15,6 @@ export default class AuthenticatorImpl implements Authenticator {
|
|
|
15
15
|
getSessionToken(): string | null;
|
|
16
16
|
getPerson(): any;
|
|
17
17
|
isLoggedIn(): boolean;
|
|
18
|
-
clearSession(): void
|
|
19
|
-
addEventListener<
|
|
20
|
-
}
|
|
21
|
-
export interface AuthenticatorEmitterMap {
|
|
22
|
-
'did-login': {
|
|
23
|
-
token: string;
|
|
24
|
-
person: Person;
|
|
25
|
-
}[];
|
|
26
|
-
'will-logout': {
|
|
27
|
-
person: Person;
|
|
28
|
-
}[];
|
|
29
|
-
'did-logout': {
|
|
30
|
-
person: Person;
|
|
31
|
-
}[];
|
|
18
|
+
clearSession(): Promise<void>;
|
|
19
|
+
addEventListener: MercuryEventEmitter<AuthContract>['on'];
|
|
32
20
|
}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { AbstractEventEmitter } from '@sprucelabs/mercury-event-emitter';
|
|
2
11
|
import SpruceError from '../errors/SpruceError.js';
|
|
12
|
+
import { authContract, } from '../types/heartwood.types.js';
|
|
3
13
|
export default class AuthenticatorImpl {
|
|
4
14
|
constructor(storage) {
|
|
5
|
-
this.
|
|
15
|
+
this.addEventListener = (name, cb) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
yield this.emitter.on(name, cb);
|
|
17
|
+
});
|
|
18
|
+
this.emitter = new AuthEmitter();
|
|
6
19
|
this.storage = storage;
|
|
7
20
|
}
|
|
8
21
|
static getInstance() {
|
|
@@ -25,7 +38,7 @@ export default class AuthenticatorImpl {
|
|
|
25
38
|
setSessionToken(token, person) {
|
|
26
39
|
this.storage.setItem('sessionToken', token);
|
|
27
40
|
this.storage.setItem('person', JSON.stringify(person));
|
|
28
|
-
this.
|
|
41
|
+
void this.emitter.emit('did-login', { token, person });
|
|
29
42
|
}
|
|
30
43
|
getSessionToken() {
|
|
31
44
|
var _a;
|
|
@@ -39,18 +52,21 @@ export default class AuthenticatorImpl {
|
|
|
39
52
|
return !!this.getSessionToken();
|
|
40
53
|
}
|
|
41
54
|
clearSession() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
var _a;
|
|
57
|
+
if (!this.isLoggedIn()) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const person = JSON.parse((_a = this.storage.getItem('person')) !== null && _a !== void 0 ? _a : '{}');
|
|
61
|
+
yield this.emitter.emit('will-logout', { person });
|
|
62
|
+
this.storage.removeItem('sessionToken');
|
|
63
|
+
this.storage.removeItem('person');
|
|
64
|
+
yield this.emitter.emit('did-logout', { person });
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
class AuthEmitter extends AbstractEventEmitter {
|
|
69
|
+
constructor() {
|
|
70
|
+
super(authContract);
|
|
55
71
|
}
|
|
56
72
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DateUtil, Locale as ILocale, TimezoneName as ITimezoneName } from '@sprucelabs/calendar-utils';
|
|
2
2
|
import { MercuryClient, MercuryClientFactory } from '@sprucelabs/mercury-client';
|
|
3
|
-
import { PermissionContractId, PermissionId, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
4
|
-
import { AddressFieldValue, FieldDefinitions, FieldError, Schema, SchemaFieldNames, SchemaPartialValues } from '@sprucelabs/schema';
|
|
3
|
+
import { MercuryEventEmitter, PermissionContractId, PermissionId, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
4
|
+
import { AddressFieldValue, FieldDefinitions, FieldError, Schema, SchemaFieldNames, SchemaPartialValues, SchemaValues } from '@sprucelabs/schema';
|
|
5
5
|
import { Log } from '@sprucelabs/spruce-skill-utils';
|
|
6
6
|
import { BarChartViewController, CalendarEventOptions, PagerViewController } from '..';
|
|
7
7
|
import { fancyIcons, lineIcons } from '../constants';
|
|
@@ -44,31 +44,99 @@ import '@sprucelabs/mercury-core-events';
|
|
|
44
44
|
export { default as MapViewController } from '../viewControllers/Map.vc';
|
|
45
45
|
export type ErrorHandler = (message: string) => void;
|
|
46
46
|
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
type
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
export declare const didLoginPayload: {
|
|
48
|
+
id: string;
|
|
49
|
+
fields: {
|
|
50
|
+
token: {
|
|
51
|
+
type: "text";
|
|
52
|
+
isRequired: true;
|
|
53
|
+
};
|
|
54
|
+
person: {
|
|
55
|
+
type: "schema";
|
|
56
|
+
isRequired: true;
|
|
57
|
+
options: {
|
|
58
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare const didLogoutPayload: {
|
|
64
|
+
id: string;
|
|
65
|
+
fields: {
|
|
66
|
+
person: {
|
|
67
|
+
type: "schema";
|
|
68
|
+
isRequired: true;
|
|
69
|
+
options: {
|
|
70
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type DidLoginPayload = SchemaValues<typeof didLoginPayload>;
|
|
76
|
+
export type DidLogoutPayload = SchemaValues<typeof didLogoutPayload>;
|
|
60
77
|
export interface Storage {
|
|
61
78
|
removeItem(key: string): void;
|
|
62
79
|
setItem(key: string, value: string): void;
|
|
63
80
|
getItem(key: string): string | null;
|
|
64
81
|
}
|
|
82
|
+
export declare const authContract: {
|
|
83
|
+
eventSignatures: {
|
|
84
|
+
'did-login': {
|
|
85
|
+
emitPayloadSchema: {
|
|
86
|
+
id: string;
|
|
87
|
+
fields: {
|
|
88
|
+
token: {
|
|
89
|
+
type: "text";
|
|
90
|
+
isRequired: true;
|
|
91
|
+
};
|
|
92
|
+
person: {
|
|
93
|
+
type: "schema";
|
|
94
|
+
isRequired: true;
|
|
95
|
+
options: {
|
|
96
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
'will-logout': {
|
|
103
|
+
emitPayloadSchema: {
|
|
104
|
+
id: string;
|
|
105
|
+
fields: {
|
|
106
|
+
person: {
|
|
107
|
+
type: "schema";
|
|
108
|
+
isRequired: true;
|
|
109
|
+
options: {
|
|
110
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
'did-logout': {
|
|
117
|
+
emitPayloadSchema: {
|
|
118
|
+
id: string;
|
|
119
|
+
fields: {
|
|
120
|
+
person: {
|
|
121
|
+
type: "schema";
|
|
122
|
+
isRequired: true;
|
|
123
|
+
options: {
|
|
124
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export type AuthContract = typeof authContract;
|
|
65
133
|
export interface Authenticator {
|
|
66
134
|
getPerson(): Person | null;
|
|
67
135
|
setSessionToken(token: string, person: Person): void;
|
|
68
136
|
getSessionToken(): string | null;
|
|
69
137
|
isLoggedIn(): boolean;
|
|
70
|
-
clearSession(): void
|
|
71
|
-
addEventListener<
|
|
138
|
+
clearSession(): Promise<void>;
|
|
139
|
+
addEventListener: MercuryEventEmitter<AuthContract>['on'];
|
|
72
140
|
}
|
|
73
141
|
export interface AuthenticatorStatic {
|
|
74
142
|
getInstance(): Authenticator;
|
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
import { buildEventContract, } from '@sprucelabs/mercury-types';
|
|
2
|
+
import { buildSchema, } from '@sprucelabs/schema';
|
|
3
|
+
import { personSchema } from '@sprucelabs/spruce-core-schemas';
|
|
1
4
|
export * from './calendar.types.js';
|
|
2
5
|
import '@sprucelabs/mercury-core-events';
|
|
3
6
|
export { default as MapViewController } from '../viewControllers/Map.vc.js';
|
|
7
|
+
export const didLoginPayload = buildSchema({
|
|
8
|
+
id: 'authDidLoginPayload',
|
|
9
|
+
fields: {
|
|
10
|
+
token: {
|
|
11
|
+
type: 'text',
|
|
12
|
+
isRequired: true,
|
|
13
|
+
},
|
|
14
|
+
person: {
|
|
15
|
+
type: 'schema',
|
|
16
|
+
isRequired: true,
|
|
17
|
+
options: {
|
|
18
|
+
schema: personSchema,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
export const didLogoutPayload = buildSchema({
|
|
24
|
+
id: 'authDidLogoutPayload',
|
|
25
|
+
fields: {
|
|
26
|
+
person: {
|
|
27
|
+
type: 'schema',
|
|
28
|
+
isRequired: true,
|
|
29
|
+
options: {
|
|
30
|
+
schema: personSchema,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export const authContract = buildEventContract({
|
|
36
|
+
eventSignatures: {
|
|
37
|
+
'did-login': {
|
|
38
|
+
emitPayloadSchema: didLoginPayload,
|
|
39
|
+
},
|
|
40
|
+
'will-logout': {
|
|
41
|
+
emitPayloadSchema: didLogoutPayload,
|
|
42
|
+
},
|
|
43
|
+
'did-logout': {
|
|
44
|
+
emitPayloadSchema: didLogoutPayload,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DateUtil, Locale as ILocale, TimezoneName as ITimezoneName } from '@sprucelabs/calendar-utils';
|
|
2
2
|
import { MercuryClient, MercuryClientFactory } from '@sprucelabs/mercury-client';
|
|
3
|
-
import { PermissionContractId, PermissionId, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
4
|
-
import { AddressFieldValue, FieldDefinitions, FieldError, Schema, SchemaFieldNames, SchemaPartialValues } from '@sprucelabs/schema';
|
|
3
|
+
import { MercuryEventEmitter, PermissionContractId, PermissionId, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
4
|
+
import { AddressFieldValue, FieldDefinitions, FieldError, Schema, SchemaFieldNames, SchemaPartialValues, SchemaValues } from '@sprucelabs/schema';
|
|
5
5
|
import { Log } from '@sprucelabs/spruce-skill-utils';
|
|
6
6
|
import { BarChartViewController, CalendarEventOptions, PagerViewController } from '..';
|
|
7
7
|
import { fancyIcons, lineIcons } from '../constants';
|
|
@@ -44,31 +44,99 @@ import '@sprucelabs/mercury-core-events';
|
|
|
44
44
|
export { default as MapViewController } from '../viewControllers/Map.vc';
|
|
45
45
|
export type ErrorHandler = (message: string) => void;
|
|
46
46
|
type Person = SpruceSchemas.Spruce.v2020_07_22.Person;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
type
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
export declare const didLoginPayload: {
|
|
48
|
+
id: string;
|
|
49
|
+
fields: {
|
|
50
|
+
token: {
|
|
51
|
+
type: "text";
|
|
52
|
+
isRequired: true;
|
|
53
|
+
};
|
|
54
|
+
person: {
|
|
55
|
+
type: "schema";
|
|
56
|
+
isRequired: true;
|
|
57
|
+
options: {
|
|
58
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare const didLogoutPayload: {
|
|
64
|
+
id: string;
|
|
65
|
+
fields: {
|
|
66
|
+
person: {
|
|
67
|
+
type: "schema";
|
|
68
|
+
isRequired: true;
|
|
69
|
+
options: {
|
|
70
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type DidLoginPayload = SchemaValues<typeof didLoginPayload>;
|
|
76
|
+
export type DidLogoutPayload = SchemaValues<typeof didLogoutPayload>;
|
|
60
77
|
export interface Storage {
|
|
61
78
|
removeItem(key: string): void;
|
|
62
79
|
setItem(key: string, value: string): void;
|
|
63
80
|
getItem(key: string): string | null;
|
|
64
81
|
}
|
|
82
|
+
export declare const authContract: {
|
|
83
|
+
eventSignatures: {
|
|
84
|
+
'did-login': {
|
|
85
|
+
emitPayloadSchema: {
|
|
86
|
+
id: string;
|
|
87
|
+
fields: {
|
|
88
|
+
token: {
|
|
89
|
+
type: "text";
|
|
90
|
+
isRequired: true;
|
|
91
|
+
};
|
|
92
|
+
person: {
|
|
93
|
+
type: "schema";
|
|
94
|
+
isRequired: true;
|
|
95
|
+
options: {
|
|
96
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
'will-logout': {
|
|
103
|
+
emitPayloadSchema: {
|
|
104
|
+
id: string;
|
|
105
|
+
fields: {
|
|
106
|
+
person: {
|
|
107
|
+
type: "schema";
|
|
108
|
+
isRequired: true;
|
|
109
|
+
options: {
|
|
110
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
'did-logout': {
|
|
117
|
+
emitPayloadSchema: {
|
|
118
|
+
id: string;
|
|
119
|
+
fields: {
|
|
120
|
+
person: {
|
|
121
|
+
type: "schema";
|
|
122
|
+
isRequired: true;
|
|
123
|
+
options: {
|
|
124
|
+
schema: SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export type AuthContract = typeof authContract;
|
|
65
133
|
export interface Authenticator {
|
|
66
134
|
getPerson(): Person | null;
|
|
67
135
|
setSessionToken(token: string, person: Person): void;
|
|
68
136
|
getSessionToken(): string | null;
|
|
69
137
|
isLoggedIn(): boolean;
|
|
70
|
-
clearSession(): void
|
|
71
|
-
addEventListener<
|
|
138
|
+
clearSession(): Promise<void>;
|
|
139
|
+
addEventListener: MercuryEventEmitter<AuthContract>['on'];
|
|
72
140
|
}
|
|
73
141
|
export interface AuthenticatorStatic {
|
|
74
142
|
getInstance(): Authenticator;
|
|
@@ -17,8 +17,52 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.MapViewController = void 0;
|
|
20
|
+
exports.authContract = exports.didLogoutPayload = exports.didLoginPayload = exports.MapViewController = void 0;
|
|
21
|
+
const mercury_types_1 = require("@sprucelabs/mercury-types");
|
|
22
|
+
const schema_1 = require("@sprucelabs/schema");
|
|
23
|
+
const spruce_core_schemas_1 = require("@sprucelabs/spruce-core-schemas");
|
|
21
24
|
__exportStar(require("./calendar.types"), exports);
|
|
22
25
|
require("@sprucelabs/mercury-core-events");
|
|
23
26
|
var Map_vc_1 = require("../viewControllers/Map.vc");
|
|
24
27
|
Object.defineProperty(exports, "MapViewController", { enumerable: true, get: function () { return __importDefault(Map_vc_1).default; } });
|
|
28
|
+
exports.didLoginPayload = (0, schema_1.buildSchema)({
|
|
29
|
+
id: 'authDidLoginPayload',
|
|
30
|
+
fields: {
|
|
31
|
+
token: {
|
|
32
|
+
type: 'text',
|
|
33
|
+
isRequired: true,
|
|
34
|
+
},
|
|
35
|
+
person: {
|
|
36
|
+
type: 'schema',
|
|
37
|
+
isRequired: true,
|
|
38
|
+
options: {
|
|
39
|
+
schema: spruce_core_schemas_1.personSchema,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
exports.didLogoutPayload = (0, schema_1.buildSchema)({
|
|
45
|
+
id: 'authDidLogoutPayload',
|
|
46
|
+
fields: {
|
|
47
|
+
person: {
|
|
48
|
+
type: 'schema',
|
|
49
|
+
isRequired: true,
|
|
50
|
+
options: {
|
|
51
|
+
schema: spruce_core_schemas_1.personSchema,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
exports.authContract = (0, mercury_types_1.buildEventContract)({
|
|
57
|
+
eventSignatures: {
|
|
58
|
+
'did-login': {
|
|
59
|
+
emitPayloadSchema: exports.didLoginPayload,
|
|
60
|
+
},
|
|
61
|
+
'will-logout': {
|
|
62
|
+
emitPayloadSchema: exports.didLogoutPayload,
|
|
63
|
+
},
|
|
64
|
+
'did-logout': {
|
|
65
|
+
emitPayloadSchema: exports.didLogoutPayload,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
package/package.json
CHANGED