wirejs-resources 0.1.2-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/index.js CHANGED
@@ -2,4 +2,5 @@ export { FileService } from './services/file.js';
2
2
  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
- export { Resource } from './resource.js';
5
+ export { Resource } from './resource.js';
6
+ export { overrides } from './overrides.js';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Used by hosting providers to provide service overrides.
3
+ */
4
+ export const overrides = {};
@@ -1,6 +1,7 @@
1
1
  import crypto from 'crypto';
2
2
  import { Resource } from '../resource.js';
3
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 FileService(this, 'files');
25
+ this.#fileService = new (overrides.FileService || FileService)(this, 'files');
25
26
 
26
27
  this.#initPromise = this.#fileService.write(
27
28
  FILENAME,
@@ -3,10 +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 { Secret } from '../resources/secret.js';
7
6
  import { FileService } from './file.js';
8
- import { CookieJar } from '../adapters/cookie-jar.js';
7
+ import { Secret } from '../resources/secret.js';
9
8
  import { withContext } from '../adapters/context.js';
9
+ import { overrides } from '../overrides.js';
10
10
 
11
11
 
12
12
  /**
@@ -36,6 +36,8 @@ async function verifyHash(password, passwordHash) {
36
36
  return rehashed === passwordHash;
37
37
  }
38
38
 
39
+ // #region types
40
+
39
41
  /**
40
42
  * @typedef {{
41
43
  * id: string;
@@ -99,6 +101,8 @@ async function verifyHash(password, passwordHash) {
99
101
  * @property {string} [cookie] - The name of the cookie to use to store the authentication state JWT.
100
102
  */
101
103
 
104
+ // #endregion
105
+
102
106
  const ONE_WEEK = 7 * 24 * 60 * 60; // days * hours/day * minutes/hour * seconds/minute
103
107
 
104
108
  export class AuthenticationService extends Resource {
@@ -131,8 +135,8 @@ export class AuthenticationService extends Resource {
131
135
  this.#keepalive = !!keepalive;
132
136
  this.#cookieName = cookie ?? 'identity';
133
137
 
134
- this.#rawSigningSecret = new Secret(this, 'jwt-signing-secret');
135
- const fileService = new FileService(this, 'files');
138
+ this.#rawSigningSecret = new (overrides.Secret || Secret)(this, 'jwt-signing-secret');
139
+ const fileService = new (overrides.FileService || FileService)(this, 'files');
136
140
 
137
141
  this.#users = {
138
142
  id,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-resources",
3
- "version": "0.1.2-alpha",
3
+ "version": "0.1.4-alpha",
4
4
  "description": "Basic services and server-side resources for wirejs apps",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",