wirejs-resources 0.1.3-alpha → 0.1.4-alpha
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/lib/adapters/context.js +3 -3
- package/lib/index.js +1 -1
- package/lib/overrides.js +4 -0
- package/lib/resources/secret.js +3 -2
- package/lib/services/authentication.js +10 -8
- package/lib/types.ts +1 -0
- package/package.json +1 -1
- package/lib/registry.js +0 -13
package/lib/adapters/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CookieJar } from "./cookie-jar.js";
|
|
2
2
|
|
|
3
3
|
const contextWrappers = new Set();
|
|
4
4
|
|
|
@@ -76,7 +76,7 @@ export function requiresContext(fnOrNS) {
|
|
|
76
76
|
|
|
77
77
|
export class Context {
|
|
78
78
|
/**
|
|
79
|
-
* @type {
|
|
79
|
+
* @type {CookieJar} cookies
|
|
80
80
|
*/
|
|
81
81
|
cookies;
|
|
82
82
|
|
|
@@ -87,7 +87,7 @@ export class Context {
|
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* @param {{
|
|
90
|
-
* cookies:
|
|
90
|
+
* cookies: CookieJar;
|
|
91
91
|
* location: URL;
|
|
92
92
|
* }}
|
|
93
93
|
*/
|
package/lib/index.js
CHANGED
|
@@ -3,4 +3,4 @@ export { AuthenticationService } from './services/authentication.js';
|
|
|
3
3
|
export { CookieJar } from './adapters/cookie-jar.js';
|
|
4
4
|
export { withContext, requiresContext, Context } from './adapters/context.js';
|
|
5
5
|
export { Resource } from './resource.js';
|
|
6
|
-
export {
|
|
6
|
+
export { overrides } from './overrides.js';
|
package/lib/overrides.js
ADDED
package/lib/resources/secret.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from 'crypto';
|
|
2
2
|
import { Resource } from '../resource.js';
|
|
3
|
-
import {
|
|
3
|
+
import { FileService } from '../services/file.js';
|
|
4
|
+
import { overrides } from '../overrides.js';
|
|
4
5
|
|
|
5
6
|
const FILENAME = 'secret';
|
|
6
7
|
|
|
@@ -21,7 +22,7 @@ export class Secret extends Resource {
|
|
|
21
22
|
*/
|
|
22
23
|
constructor(scope, id) {
|
|
23
24
|
super(scope, id);
|
|
24
|
-
this.#fileService = new
|
|
25
|
+
this.#fileService = new (overrides.FileService || FileService)(this, 'files');
|
|
25
26
|
|
|
26
27
|
this.#initPromise = this.#fileService.write(
|
|
27
28
|
FILENAME,
|
|
@@ -3,8 +3,10 @@ import { scrypt, randomBytes } from 'crypto';
|
|
|
3
3
|
import * as jose from 'jose';
|
|
4
4
|
|
|
5
5
|
import { Resource } from '../resource.js';
|
|
6
|
+
import { FileService } from './file.js';
|
|
7
|
+
import { Secret } from '../resources/secret.js';
|
|
6
8
|
import { withContext } from '../adapters/context.js';
|
|
7
|
-
import {
|
|
9
|
+
import { overrides } from '../overrides.js';
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -109,7 +111,7 @@ export class AuthenticationService extends Resource {
|
|
|
109
111
|
#cookieName;
|
|
110
112
|
|
|
111
113
|
/**
|
|
112
|
-
* @type {
|
|
114
|
+
* @type {Secret}
|
|
113
115
|
*/
|
|
114
116
|
#rawSigningSecret;
|
|
115
117
|
|
|
@@ -133,8 +135,8 @@ export class AuthenticationService extends Resource {
|
|
|
133
135
|
this.#keepalive = !!keepalive;
|
|
134
136
|
this.#cookieName = cookie ?? 'identity';
|
|
135
137
|
|
|
136
|
-
this.#rawSigningSecret = new
|
|
137
|
-
const fileService = new
|
|
138
|
+
this.#rawSigningSecret = new (overrides.Secret || Secret)(this, 'jwt-signing-secret');
|
|
139
|
+
const fileService = new (overrides.FileService || FileService)(this, 'files');
|
|
138
140
|
|
|
139
141
|
this.#users = {
|
|
140
142
|
id,
|
|
@@ -194,7 +196,7 @@ export class AuthenticationService extends Resource {
|
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
/**
|
|
197
|
-
* @param {
|
|
199
|
+
* @param {CookieJar} cookies
|
|
198
200
|
* @returns {Promise<AuthenticationBaseState>}
|
|
199
201
|
*/
|
|
200
202
|
async getBaseState(cookies) {
|
|
@@ -225,7 +227,7 @@ export class AuthenticationService extends Resource {
|
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
/**
|
|
228
|
-
* @param {
|
|
230
|
+
* @param {CookieJar} cookies
|
|
229
231
|
* @returns {Promise<AuthenticationState>}
|
|
230
232
|
*/
|
|
231
233
|
async getState(cookies) {
|
|
@@ -293,7 +295,7 @@ export class AuthenticationService extends Resource {
|
|
|
293
295
|
|
|
294
296
|
/**
|
|
295
297
|
*
|
|
296
|
-
* @param {
|
|
298
|
+
* @param {CookieJar} cookies
|
|
297
299
|
* @param {string | undefined} [user]
|
|
298
300
|
*/
|
|
299
301
|
async setBaseState(cookies, user) {
|
|
@@ -338,7 +340,7 @@ export class AuthenticationService extends Resource {
|
|
|
338
340
|
}
|
|
339
341
|
|
|
340
342
|
/**
|
|
341
|
-
* @param {
|
|
343
|
+
* @param {CookieJar} cookies
|
|
342
344
|
* @param {PerformActionParameter} params
|
|
343
345
|
* @returns {Promise<AuthenticationState | { errors: AuthenticationError[] }>}
|
|
344
346
|
*/
|
package/lib/types.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare class Context extends ContextBase {};
|
|
|
11
11
|
export declare class AuthenticationService extends AuthenticationServiceBase {};
|
|
12
12
|
export declare class FileService extends FileServiceBase {};
|
|
13
13
|
export declare function withContext(): typeof withContextBase;
|
|
14
|
+
export declare const overrides: any;
|
package/package.json
CHANGED
package/lib/registry.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Context } from './adapters/context.js';
|
|
2
|
-
import { CookieJar } from './adapters/cookie-jar.js';
|
|
3
|
-
import { Secret } from './resources/secret.js';
|
|
4
|
-
import { AuthenticationService } from './services/authentication.js'
|
|
5
|
-
import { FileService } from './services/file.js';
|
|
6
|
-
|
|
7
|
-
export const registry = /** @type {const} **/ ({
|
|
8
|
-
Context,
|
|
9
|
-
CookieJar,
|
|
10
|
-
Secret,
|
|
11
|
-
AuthenticationService,
|
|
12
|
-
FileService
|
|
13
|
-
});
|