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.
@@ -1,4 +1,4 @@
1
- import { registry } from "../registry";
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 {typeof registry['CookieJar']} cookies
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: typeof registry['CookieJar'];
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 { registry } from './registry.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
- import { registry } from '../registry.js';
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 registry.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,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 { registry } from '../registry.js';
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 {typeof registry['Secret']}
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 registry.Secret(this, 'jwt-signing-secret');
137
- const fileService = new registry.FileService(this, 'files');
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 {typeof registry['CookieJar']} cookies
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 {typeof registry['CookieJar']} cookies
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 {typeof registry['CookieJar']} cookies
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 {typeof registry['CookieJar']} cookies
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-resources",
3
- "version": "0.1.3-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",
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
- });