@sasjs/api 0.25.0 → 0.26.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/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.25.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.26.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
2
2
  "use strict";
3
3
  var SASjsApi = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -5413,7 +5413,8 @@ var SASjsApi = (() => {
5413
5413
  authProvider: user3.authProvider,
5414
5414
  autoExec: user3.autoExec
5415
5415
  });
5416
- this.passwords.set(user3.uid, user3.password);
5416
+ if (user3.password !== void 0)
5417
+ this.passwords.set(user3.uid, user3.password);
5417
5418
  }
5418
5419
  for (const client of fixture.clients) {
5419
5420
  this.clientMap.set(client.clientId, {
@@ -5697,6 +5698,52 @@ var SASjsApi = (() => {
5697
5698
  });
5698
5699
  return input;
5699
5700
  }
5701
+ /**
5702
+ * The fixture this store would be seeded from now.
5703
+ *
5704
+ * A host that persists the store - the browser build keeps it beside the
5705
+ * drive - writes this object and seeds the next boot from it, so the file a
5706
+ * person reads and the object the store speaks are the same shape. Passwords
5707
+ * are carried because a seed needs them to sign in: the administration
5708
+ * records deliberately leave them out, and a snapshot that did too would be a
5709
+ * fixture no one could log into.
5710
+ *
5711
+ * Tokens and authorization codes are absent on purpose. They are credentials
5712
+ * with a lifetime, minted per session; a persisted one would authenticate a
5713
+ * caller after the pair it names had been rotated or revoked, which is the
5714
+ * failure a token store exists to prevent.
5715
+ *
5716
+ * An account with no local password - one a directory imported, or one
5717
+ * created and never given a password - is stated without one. Writing an
5718
+ * empty string would seed an account the equality check signs in with `''`,
5719
+ * while an absent password refuses every attempt, which is what this store
5720
+ * itself answers for that account.
5721
+ */
5722
+ snapshot() {
5723
+ return {
5724
+ format: IDENTITY_FORMAT,
5725
+ users: this.userList.map((user3) => {
5726
+ const password = this.passwords.get(user3.uid);
5727
+ return {
5728
+ ...user3,
5729
+ ...password === void 0 ? {} : { password }
5730
+ };
5731
+ }),
5732
+ groups: [...this.groupList.values()].map((group) => ({
5733
+ ...group,
5734
+ // the store holds members as uids; the fixture states them by username,
5735
+ // which is what the constructor resolves back - writing uids here would
5736
+ // seed a group whose membership matches no account
5737
+ users: group.users.map(
5738
+ (uid) => this.userList.find((user3) => user3.uid === uid)?.username
5739
+ ).filter((username) => username !== void 0)
5740
+ })),
5741
+ permissions: [...this.permissionList.values()].map((permission) => ({
5742
+ ...permission
5743
+ })),
5744
+ clients: [...this.clientRecords.values()].map((client) => ({ ...client }))
5745
+ };
5746
+ }
5700
5747
  };
5701
5748
 
5702
5749
  // src/corpus/drive.ts
@@ -66,7 +66,11 @@ class MemoryIdentityStore {
66
66
  authProvider: user.authProvider,
67
67
  autoExec: user.autoExec
68
68
  });
69
- this.passwords.set(user.uid, user.password);
69
+ // a fixture states no password for an account whose password lives at
70
+ // its provider - a directory import writes exactly that shape - and an
71
+ // absent entry is what refuses every attempt, empty string included
72
+ if (user.password !== undefined)
73
+ this.passwords.set(user.uid, user.password);
70
74
  }
71
75
  for (const client of fixture.clients) {
72
76
  this.clientMap.set(client.clientId, {
@@ -379,5 +383,51 @@ class MemoryIdentityStore {
379
383
  });
380
384
  return input;
381
385
  }
386
+ /**
387
+ * The fixture this store would be seeded from now.
388
+ *
389
+ * A host that persists the store - the browser build keeps it beside the
390
+ * drive - writes this object and seeds the next boot from it, so the file a
391
+ * person reads and the object the store speaks are the same shape. Passwords
392
+ * are carried because a seed needs them to sign in: the administration
393
+ * records deliberately leave them out, and a snapshot that did too would be a
394
+ * fixture no one could log into.
395
+ *
396
+ * Tokens and authorization codes are absent on purpose. They are credentials
397
+ * with a lifetime, minted per session; a persisted one would authenticate a
398
+ * caller after the pair it names had been rotated or revoked, which is the
399
+ * failure a token store exists to prevent.
400
+ *
401
+ * An account with no local password - one a directory imported, or one
402
+ * created and never given a password - is stated without one. Writing an
403
+ * empty string would seed an account the equality check signs in with `''`,
404
+ * while an absent password refuses every attempt, which is what this store
405
+ * itself answers for that account.
406
+ */
407
+ snapshot() {
408
+ return {
409
+ format: fixture_js_1.IDENTITY_FORMAT,
410
+ users: this.userList.map((user) => {
411
+ const password = this.passwords.get(user.uid);
412
+ return {
413
+ ...user,
414
+ ...(password === undefined ? {} : { password })
415
+ };
416
+ }),
417
+ groups: [...this.groupList.values()].map((group) => ({
418
+ ...group,
419
+ // the store holds members as uids; the fixture states them by username,
420
+ // which is what the constructor resolves back - writing uids here would
421
+ // seed a group whose membership matches no account
422
+ users: group.users
423
+ .map((uid) => this.userList.find((user) => user.uid === uid)?.username)
424
+ .filter((username) => username !== undefined)
425
+ })),
426
+ permissions: [...this.permissionList.values()].map((permission) => ({
427
+ ...permission
428
+ })),
429
+ clients: [...this.clientRecords.values()].map((client) => ({ ...client }))
430
+ };
431
+ }
382
432
  }
383
433
  exports.MemoryIdentityStore = MemoryIdentityStore;
@@ -14,8 +14,13 @@ export interface IdentityFixtureUser {
14
14
  uid: string;
15
15
  username: string;
16
16
  displayName: string;
17
- /** Plain text on purpose: a fixture, not a credential store. */
18
- password: string;
17
+ /**
18
+ * Plain text on purpose: a fixture, not a credential store. Absent when the
19
+ * account has no local password - one a directory imported authenticates
20
+ * there, and `createUser` leaves the password to a separate `setPassword`
21
+ * call, so a store can hold such an account as well.
22
+ */
23
+ password?: string;
19
24
  isAdmin: boolean;
20
25
  isActive: boolean;
21
26
  needsToUpdatePassword: boolean;
@@ -41,9 +46,9 @@ export interface IdentityFixturePermission {
41
46
  type: string;
42
47
  /** `Grant` or `Deny`. */
43
48
  setting: string;
44
- /** The username the rule is assigned to, when it is not a group's. */
49
+ /** The uid of the account the rule is assigned to, when it is not a group's. */
45
50
  user?: string;
46
- /** The group the rule is assigned to, when it is not a user's. */
51
+ /** The uid of the group the rule is assigned to, when it is not a user's. */
47
52
  group?: string;
48
53
  }
49
54
  export interface IdentityFixt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A;IAC9B,WAAW,EAAE,yBAAyB,EAAE,CAAA;IACxC,OAAO,EAAE,qBAAqB,EAAE,CAAA;IAChC,sDAAsD;IACtD,MAAM,CAAC,EAAE,oBAAoB,EAAE,CAAA;IAC/B,mEAAmE;IACnE,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAA;CAC9B;AAID,eAAO,MAAM,gBAAgB,EAAE,eA6E9B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,OAAO,KAAG,eA2B5C,CAAA"}
@@ -81,5 +81,27 @@ export declare class MemoryIdentityStore implements IdentityStore {
81
81
  deletePermission(uid: string): Promise<void>;
82
82
  clients(): Promise<IdentityClientRecord[]>;
83
83
  createClient(input: IdentityClientRecord): Promise<IdentityClientRecord>;
84
+ /**
85
+ * The fixture this store would be seeded from now.
86
+ *
87
+ * A host that persists the store - the browser build keeps it beside the
88
+ * drive - writes this object and seeds the next boot from it, so the file a
89
+ * person reads and the object the store speaks are the same shape. Passwords
90
+ * are carried because a seed needs them to sign in: the administration
91
+ * records deliberately leave them out, and a snapshot that did too would be a
92
+ * fixture no one could log into.
93
+ *
94
+ * Tokens and authorization codes are absent on purpose. They are credentials
95
+ * with a lifetime, minted per session; a persisted one would authenticate a
96
+ * caller after the pair it names had been rotated or revoked, which is the
97
+ * failure a token store exists to prevent.
98
+ *
99
+ * An account with no local password - one a directory imported, or one
100
+ * created and never given a password - is stated without one. Writing an
101
+ * empty string would seed an account the equality check signs in with `''`,
102
+ * while an absent password refuses every attempt, which is what this store
103
+ * itself answers for that account.
104
+ */
105
+ snapshot(): IdentityFixture;
84
106
  }
85
107
  //# sourceMappingURL=memory-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../../src/identity/memory-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB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AAC,IAAI,CAAC;IAMvC,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAOrC,eAAe,CACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAOrC,WAAW,IAAI,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAIlD,cAAc,CAClB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;IAI1C,gBAAgB,CACpB,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC,wBAAwB,CAAC;IAa9B,oBAAoB,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;IAO1C,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,OAAO,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAI1C,YAAY,CAChB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,oBAAoB,CAAC;IAUhC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,IAAI,eAAe;CA4B5B"}
@@ -63,7 +63,11 @@ export class MemoryIdentityStore {
63
63
  authProvider: user.authProvider,
64
64
  autoExec: user.autoExec
65
65
  });
66
- this.passwords.set(user.uid, user.password);
66
+ // a fixture states no password for an account whose password lives at
67
+ // its provider - a directory import writes exactly that shape - and an
68
+ // absent entry is what refuses every attempt, empty string included
69
+ if (user.password !== undefined)
70
+ this.passwords.set(user.uid, user.password);
67
71
  }
68
72
  for (const client of fixture.clients) {
69
73
  this.clientMap.set(client.clientId, {
@@ -376,4 +380,50 @@ export class MemoryIdentityStore {
376
380
  });
377
381
  return input;
378
382
  }
383
+ /**
384
+ * The fixture this store would be seeded from now.
385
+ *
386
+ * A host that persists the store - the browser build keeps it beside the
387
+ * drive - writes this object and seeds the next boot from it, so the file a
388
+ * person reads and the object the store speaks are the same shape. Passwords
389
+ * are carried because a seed needs them to sign in: the administration
390
+ * records deliberately leave them out, and a snapshot that did too would be a
391
+ * fixture no one could log into.
392
+ *
393
+ * Tokens and authorization codes are absent on purpose. They are credentials
394
+ * with a lifetime, minted per session; a persisted one would authenticate a
395
+ * caller after the pair it names had been rotated or revoked, which is the
396
+ * failure a token store exists to prevent.
397
+ *
398
+ * An account with no local password - one a directory imported, or one
399
+ * created and never given a password - is stated without one. Writing an
400
+ * empty string would seed an account the equality check signs in with `''`,
401
+ * while an absent password refuses every attempt, which is what this store
402
+ * itself answers for that account.
403
+ */
404
+ snapshot() {
405
+ return {
406
+ format: IDENTITY_FORMAT,
407
+ users: this.userList.map((user) => {
408
+ const password = this.passwords.get(user.uid);
409
+ return {
410
+ ...user,
411
+ ...(password === undefined ? {} : { password })
412
+ };
413
+ }),
414
+ groups: [...this.groupList.values()].map((group) => ({
415
+ ...group,
416
+ // the store holds members as uids; the fixture states them by username,
417
+ // which is what the constructor resolves back - writing uids here would
418
+ // seed a group whose membership matches no account
419
+ users: group.users
420
+ .map((uid) => this.userList.find((user) => user.uid === uid)?.username)
421
+ .filter((username) => username !== undefined)
422
+ })),
423
+ permissions: [...this.permissionList.values()].map((permission) => ({
424
+ ...permission
425
+ })),
426
+ clients: [...this.clientRecords.values()].map((client) => ({ ...client }))
427
+ };
428
+ }
379
429
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "The SASjs Server API, described once - a generated route table, the services behind it, and the conformance corpus both hosts run",
5
5
  "license": "MIT",
6
6
  "author": "SASjs",