@sasjs/api 0.49.0 → 0.50.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/README.md +11 -0
- package/build/browser.js +407 -47
- package/build/cjs/appstream/identity.js +2 -31
- package/build/cjs/uuid.js +30 -0
- package/build/cjs/viya/appSurface.js +241 -0
- package/build/cjs/viya/compute.js +71 -20
- package/build/cjs/viya/declared.js +96 -0
- package/build/cjs/viya/dispatch.js +10 -0
- package/build/cjs/viya/identity.js +191 -0
- package/build/cjs/viya/overlay.js +10 -0
- package/build/cjs/viya/seed.js +34 -8
- package/build/cjs/viya/service.js +3 -1
- package/build/cjs/viya/sessions.js +24 -10
- package/build/esm/appstream/identity.d.ts +1 -9
- package/build/esm/appstream/identity.d.ts.map +1 -1
- package/build/esm/appstream/identity.js +1 -30
- package/build/esm/identity/types.d.ts +2 -0
- package/build/esm/identity/types.d.ts.map +1 -1
- package/build/esm/uuid.d.ts +6 -0
- package/build/esm/uuid.d.ts.map +1 -0
- package/build/esm/uuid.js +26 -0
- package/build/esm/viya/appSurface.d.ts +51 -0
- package/build/esm/viya/appSurface.d.ts.map +1 -0
- package/build/esm/viya/appSurface.js +238 -0
- package/build/esm/viya/compute.d.ts.map +1 -1
- package/build/esm/viya/compute.js +73 -22
- package/build/esm/viya/declared.d.ts.map +1 -1
- package/build/esm/viya/declared.js +96 -0
- package/build/esm/viya/dispatch.d.ts +3 -0
- package/build/esm/viya/dispatch.d.ts.map +1 -1
- package/build/esm/viya/dispatch.js +11 -1
- package/build/esm/viya/identity.d.ts +34 -0
- package/build/esm/viya/identity.d.ts.map +1 -0
- package/build/esm/viya/identity.js +187 -0
- package/build/esm/viya/overlay.d.ts.map +1 -1
- package/build/esm/viya/overlay.js +10 -0
- package/build/esm/viya/seed.d.ts +29 -7
- package/build/esm/viya/seed.d.ts.map +1 -1
- package/build/esm/viya/seed.js +32 -7
- package/build/esm/viya/service.d.ts.map +1 -1
- package/build/esm/viya/service.js +3 -1
- package/build/esm/viya/sessions.d.ts +24 -6
- package/build/esm/viya/sessions.d.ts.map +1 -1
- package/build/esm/viya/sessions.js +24 -10
- package/package.json +3 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IDENTITY_HANDLERS = exports.requireRecords = void 0;
|
|
4
|
+
const types_js_1 = require("../types.js");
|
|
5
|
+
const ids_js_1 = require("./ids.js");
|
|
6
|
+
/** The port these handlers read, or the capability the host did not supply. */
|
|
7
|
+
const requireRecords = (services) => {
|
|
8
|
+
if (!services.records)
|
|
9
|
+
throw new types_js_1.ApiError(501, 'The emulated identity answers from the records service, which this host does not supply.');
|
|
10
|
+
return services.records;
|
|
11
|
+
};
|
|
12
|
+
exports.requireRecords = requireRecords;
|
|
13
|
+
/**
|
|
14
|
+
* The caller, from the subject a host resolved or from the token it forwarded.
|
|
15
|
+
*
|
|
16
|
+
* A host that already knows its caller passes `subject`; one that hands the
|
|
17
|
+
* emulator a bearer token (the server's Viya router does) gets the token read
|
|
18
|
+
* here, exactly as `GET /identities/users/@currentUser` reads it. Neither is
|
|
19
|
+
* optional in effect: an unauthenticated caller has no identity to answer about.
|
|
20
|
+
*/
|
|
21
|
+
const callerOf = async (services, request) => request.subject ?? (await services.identity?.authenticate(request.token));
|
|
22
|
+
/**
|
|
23
|
+
* The `{}` a membership or avatar read was addressed to, as a uid.
|
|
24
|
+
*
|
|
25
|
+
* `@currentUser` is where Viya puts the caller's own account, and a client asks
|
|
26
|
+
* for it by that spelling. It is resolved here rather than given its own row so
|
|
27
|
+
* the handler has one shape to answer.
|
|
28
|
+
*/
|
|
29
|
+
const userIdFrom = (segment, caller) => {
|
|
30
|
+
if (segment.toLowerCase() !== '@currentuser')
|
|
31
|
+
return segment;
|
|
32
|
+
const id = caller?.userId;
|
|
33
|
+
if (!id)
|
|
34
|
+
throw new types_js_1.ApiError(401, 'No caller is signed in.');
|
|
35
|
+
return id;
|
|
36
|
+
};
|
|
37
|
+
/** The paging fields every collection answer carries, as the captured ones do. */
|
|
38
|
+
const collection = (name, items, limit, uri, type) => {
|
|
39
|
+
const page = limit > 0 ? items.slice(0, limit) : items;
|
|
40
|
+
return {
|
|
41
|
+
accept: 'application/json',
|
|
42
|
+
name,
|
|
43
|
+
start: 0,
|
|
44
|
+
// the value asked for is echoed, as the folder answers echo it: a caller
|
|
45
|
+
// that asked for five and is told zero cannot tell what happened
|
|
46
|
+
limit: limit || page.length,
|
|
47
|
+
count: page.length,
|
|
48
|
+
version: 2,
|
|
49
|
+
items: page,
|
|
50
|
+
links: [
|
|
51
|
+
{
|
|
52
|
+
href: uri,
|
|
53
|
+
uri,
|
|
54
|
+
rel: 'self',
|
|
55
|
+
method: 'GET',
|
|
56
|
+
type: 'application/vnd.sas.collection',
|
|
57
|
+
itemType: type
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const identityLinks = (uri, type) => [
|
|
63
|
+
{ href: uri, uri, rel: 'self', method: 'GET', type }
|
|
64
|
+
];
|
|
65
|
+
const GROUP_TYPE = 'application/vnd.sas.identity.group';
|
|
66
|
+
const USER_TYPE = 'application/vnd.sas.identity.user';
|
|
67
|
+
/** A group as Viya represents one, from the store's record. */
|
|
68
|
+
const groupBody = (group, memberCount) => ({
|
|
69
|
+
id: group.uid,
|
|
70
|
+
name: group.name,
|
|
71
|
+
description: group.description,
|
|
72
|
+
providerId: 'sas',
|
|
73
|
+
state: 'active',
|
|
74
|
+
memberCount,
|
|
75
|
+
creationTimeStamp: ids_js_1.EMULATED_NOW,
|
|
76
|
+
modifiedTimeStamp: ids_js_1.EMULATED_NOW,
|
|
77
|
+
version: 1,
|
|
78
|
+
links: identityLinks(`/identities/groups/${group.uid}`, GROUP_TYPE)
|
|
79
|
+
});
|
|
80
|
+
/** A user as Viya represents one. */
|
|
81
|
+
const userBody = (user) => ({
|
|
82
|
+
id: user.uid,
|
|
83
|
+
// Viya's `name` is the identifier a person signs in with; the display name is
|
|
84
|
+
// a separate field, and this is the one a member list shows
|
|
85
|
+
name: user.username,
|
|
86
|
+
displayName: user.displayName,
|
|
87
|
+
providerId: 'sas',
|
|
88
|
+
state: 'active',
|
|
89
|
+
version: 1,
|
|
90
|
+
links: identityLinks(`/identities/users/${user.uid}`, USER_TYPE)
|
|
91
|
+
});
|
|
92
|
+
/** The groups a user is a member of, as Viya's memberships route answers them. */
|
|
93
|
+
const membershipsOf = async (records, caller, uid) => {
|
|
94
|
+
const users = await records.listUsers(caller);
|
|
95
|
+
// Viya clients may address a user by login name; prefer an exact uid when a
|
|
96
|
+
// login happens to equal another user's uid.
|
|
97
|
+
const user = users.find((item) => item.uid === uid) ??
|
|
98
|
+
users.find((item) => item.username === uid);
|
|
99
|
+
const resolvedUid = user?.uid ?? uid;
|
|
100
|
+
const groups = await records.listGroups(caller);
|
|
101
|
+
const found = [];
|
|
102
|
+
for (const group of groups) {
|
|
103
|
+
const details = await records.getGroup(caller, { uid: group.uid });
|
|
104
|
+
if (details.users.some((member) => member.uid === resolvedUid))
|
|
105
|
+
found.push(groupBody(group, details.users.length));
|
|
106
|
+
}
|
|
107
|
+
return found;
|
|
108
|
+
};
|
|
109
|
+
exports.IDENTITY_HANDLERS = {
|
|
110
|
+
'GET /identities/groups': async ({ services, request }) => {
|
|
111
|
+
const records = (0, exports.requireRecords)(services);
|
|
112
|
+
const caller = await callerOf(services, request);
|
|
113
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
114
|
+
const sortBy = request.query?.sortBy;
|
|
115
|
+
const groups = await records.listGroups(caller);
|
|
116
|
+
const items = [];
|
|
117
|
+
for (const group of groups) {
|
|
118
|
+
const details = await records.getGroup(caller, { uid: group.uid });
|
|
119
|
+
items.push(groupBody(group, details.users.length));
|
|
120
|
+
}
|
|
121
|
+
// `sortBy=name` is what the application asks for, and the store's order is
|
|
122
|
+
// not one: a screen that lists groups alphabetically asks the service for it
|
|
123
|
+
const ordered = sortBy && sortBy.toLowerCase() === 'name'
|
|
124
|
+
? [...items].sort((left, right) => left.name.localeCompare(right.name))
|
|
125
|
+
: items;
|
|
126
|
+
return {
|
|
127
|
+
status: 200,
|
|
128
|
+
body: collection('groups', ordered, limit, '/identities/groups', GROUP_TYPE)
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
'GET /identities/groups/{}/members': async ({ services, request, params }) => {
|
|
132
|
+
const records = (0, exports.requireRecords)(services);
|
|
133
|
+
const caller = await callerOf(services, request);
|
|
134
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
135
|
+
const details = await records.getGroup(caller, { uid: params.id });
|
|
136
|
+
const items = details.users.map((user) => userBody(user));
|
|
137
|
+
return {
|
|
138
|
+
status: 200,
|
|
139
|
+
body: collection('members', items, limit, `/identities/groups/${details.uid}/members`, USER_TYPE)
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
'GET /identities/users': async ({ services, request }) => {
|
|
143
|
+
const records = (0, exports.requireRecords)(services);
|
|
144
|
+
const caller = await callerOf(services, request);
|
|
145
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
146
|
+
const users = await records.listUsers(caller);
|
|
147
|
+
return {
|
|
148
|
+
status: 200,
|
|
149
|
+
body: collection('users', users.map((user) => userBody(user)), limit, '/identities/users', USER_TYPE)
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
'GET /identities/users/{}': async ({ services, request, params }) => {
|
|
153
|
+
const records = (0, exports.requireRecords)(services);
|
|
154
|
+
const caller = await callerOf(services, request);
|
|
155
|
+
const uid = userIdFrom(params.id, caller);
|
|
156
|
+
const user = await records.getUser(caller, { uid });
|
|
157
|
+
return { status: 200, body: userBody(user) };
|
|
158
|
+
},
|
|
159
|
+
'GET /identities/users/@currentUser/memberships': async ({ services, request }) => {
|
|
160
|
+
const records = (0, exports.requireRecords)(services);
|
|
161
|
+
const caller = await callerOf(services, request);
|
|
162
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
163
|
+
const uid = userIdFrom('@currentUser', caller);
|
|
164
|
+
const items = await membershipsOf(records, caller, uid);
|
|
165
|
+
return {
|
|
166
|
+
status: 200,
|
|
167
|
+
body: collection('memberships', items, limit, '/identities/users/@currentUser/memberships', GROUP_TYPE)
|
|
168
|
+
};
|
|
169
|
+
},
|
|
170
|
+
'GET /identities/users/{}/memberships': async ({ services, request, params }) => {
|
|
171
|
+
const records = (0, exports.requireRecords)(services);
|
|
172
|
+
const caller = await callerOf(services, request);
|
|
173
|
+
const limit = Number(request.query?.limit ?? 0) || 0;
|
|
174
|
+
const uid = userIdFrom(params.id, caller);
|
|
175
|
+
// the address the client used is the address echoed back, as the other
|
|
176
|
+
// answers do: a client that followed a rel is never told about another one
|
|
177
|
+
const items = await membershipsOf(records, caller, uid);
|
|
178
|
+
return {
|
|
179
|
+
status: 200,
|
|
180
|
+
body: collection('memberships', items, limit, `/identities/users/${params.id}/memberships`, GROUP_TYPE)
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
'GET /identities/users/{}/avatar/content': async ({ services, request, params }) => {
|
|
184
|
+
const caller = await callerOf(services, request);
|
|
185
|
+
const uid = userIdFrom(params.id, caller);
|
|
186
|
+
// the estate's identity carries no avatar, and Viya answers a 404 for an
|
|
187
|
+
// account that has none - so a client's fallback image is what a real
|
|
188
|
+
// estate with none would show it
|
|
189
|
+
throw new types_js_1.ApiError(404, `No avatar is recorded for the user ${uid}.`);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
@@ -41,9 +41,19 @@ exports.VIYA_OVERLAY = {
|
|
|
41
41
|
'GET /folders/folders/@item': { implemented: true },
|
|
42
42
|
'GET /folders/folders/@myRecycleBin': { implemented: true },
|
|
43
43
|
'GET /identities/users/@currentUser': { implemented: true },
|
|
44
|
+
// answered here: the application's own identity reads, declared rather than
|
|
45
|
+
// captured - see src/viya/appSurface.ts for the scope they belong to
|
|
46
|
+
'GET /identities/groups': { implemented: true },
|
|
47
|
+
'GET /identities/groups/{}/members': { implemented: true },
|
|
48
|
+
'GET /identities/users': { implemented: true },
|
|
49
|
+
'GET /identities/users/{}': { implemented: true },
|
|
50
|
+
'GET /identities/users/@currentUser/memberships': { implemented: true },
|
|
51
|
+
'GET /identities/users/{}/memberships': { implemented: true },
|
|
52
|
+
'GET /identities/users/{}/avatar/content': { implemented: true },
|
|
44
53
|
'GET /types/types': { implemented: true },
|
|
45
54
|
// answered here: compute
|
|
46
55
|
'GET /compute/contexts': { implemented: true },
|
|
56
|
+
'GET /compute/contexts/{}': { implemented: true },
|
|
47
57
|
'POST /compute/contexts/{}/sessions': { implemented: true },
|
|
48
58
|
'DELETE /compute/sessions/{}': { implemented: true },
|
|
49
59
|
'POST /compute/sessions/{}/jobs': { implemented: true },
|
package/build/cjs/viya/seed.js
CHANGED
|
@@ -8,18 +8,27 @@
|
|
|
8
8
|
* true after the next one, and a fixture committed today must match the answer
|
|
9
9
|
* tomorrow.
|
|
10
10
|
*
|
|
11
|
-
* The seed is therefore the
|
|
12
|
-
* is the address clients already use to reach it,
|
|
13
|
-
* spelled two ways is one string. There is no
|
|
14
|
-
* a different estate with different data,
|
|
15
|
-
* data - a fixture, a screenshot, a test -
|
|
16
|
-
* because the address is all the identity
|
|
11
|
+
* The seed is therefore what the estate's *generated data* draws from, and the
|
|
12
|
+
* identity of an estate is the address clients already use to reach it,
|
|
13
|
+
* normalised so that one estate spelled two ways is one string. There is no
|
|
14
|
+
* override: an address that differs is a different estate with different data,
|
|
15
|
+
* by design. Anything that reads this data - a fixture, a screenshot, a test -
|
|
16
|
+
* has to work whatever the address is, because the address is all the identity
|
|
17
|
+
* there is.
|
|
18
|
+
*
|
|
19
|
+
* The seed is a 32-bit digest of that address, which is wide enough to vary the
|
|
20
|
+
* generated numbers and narrow enough that two distinct addresses collide on it
|
|
21
|
+
* - by birthday, roughly one pair per few-billion addresses, and a search finds
|
|
22
|
+
* one in minutes. A collision makes two estates answer with the same numbers,
|
|
23
|
+
* which is cosmetic; anything that *stores* state per estate - the live session
|
|
24
|
+
* registry - must therefore key by the full address, never by the seed, and
|
|
25
|
+
* `estateKeyOf` is that key.
|
|
17
26
|
*
|
|
18
27
|
* An emulator with no address has not said which estate it is, so every such
|
|
19
28
|
* estate shares one seed. That is the only honest default.
|
|
20
29
|
*/
|
|
21
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.drawFrom = exports.drawInt = exports.generator = exports.seedOf = exports.hash = exports.normaliseServerUrl = exports.DEFAULT_SEED = void 0;
|
|
31
|
+
exports.drawFrom = exports.drawInt = exports.generator = exports.estateKeyOf = exports.seedOf = exports.hash = exports.normaliseServerUrl = exports.DEFAULT_SEED = void 0;
|
|
23
32
|
/** The seed every emulated estate falls back to. */
|
|
24
33
|
exports.DEFAULT_SEED = 'emulated';
|
|
25
34
|
/**
|
|
@@ -83,13 +92,30 @@ exports.hash = hash;
|
|
|
83
92
|
* The number that makes this estate's generated data reproducible.
|
|
84
93
|
*
|
|
85
94
|
* The address is the only input: the same estate answers the same way every time,
|
|
86
|
-
* and a different address is a different estate.
|
|
95
|
+
* and a different address is a different estate. A 32-bit digest, so it varies
|
|
96
|
+
* the numbers - it is not the estate's identity for anything that stores state
|
|
97
|
+
* (see `estateKeyOf`).
|
|
87
98
|
*/
|
|
88
99
|
const seedOf = (settings = {}) => {
|
|
89
100
|
const address = (0, exports.normaliseServerUrl)(settings.serverUrl);
|
|
90
101
|
return (0, exports.hash)(`url:${address || exports.DEFAULT_SEED}`);
|
|
91
102
|
};
|
|
92
103
|
exports.seedOf = seedOf;
|
|
104
|
+
/**
|
|
105
|
+
* The key a per-estate store is held under: the full normalised address.
|
|
106
|
+
*
|
|
107
|
+
* The seed is a 32-bit digest of this key, and two distinct addresses collide
|
|
108
|
+
* on it - a pair exists for any such digest, and a search finds one in
|
|
109
|
+
* minutes. A registry keyed by the seed would then hand two addresses one
|
|
110
|
+
* shared store, so state is keyed by the address itself: distinct addresses
|
|
111
|
+
* are distinct stores even when their seeds are one number, and two spellings
|
|
112
|
+
* of one address (which normalise to one string) remain one store.
|
|
113
|
+
*/
|
|
114
|
+
const estateKeyOf = (settings = {}) => {
|
|
115
|
+
const address = (0, exports.normaliseServerUrl)(settings.serverUrl);
|
|
116
|
+
return address || exports.DEFAULT_SEED;
|
|
117
|
+
};
|
|
118
|
+
exports.estateKeyOf = estateKeyOf;
|
|
93
119
|
/**
|
|
94
120
|
* A uniform generator over one seed (mulberry32).
|
|
95
121
|
*
|
|
@@ -5,6 +5,7 @@ const types_js_1 = require("../types.js");
|
|
|
5
5
|
const ports_js_1 = require("./ports.js");
|
|
6
6
|
const compute_js_1 = require("./compute.js");
|
|
7
7
|
const files_js_1 = require("./files.js");
|
|
8
|
+
const identity_js_1 = require("./identity.js");
|
|
8
9
|
const ids_js_1 = require("./ids.js");
|
|
9
10
|
const linksFor = (uri, collection = false) => {
|
|
10
11
|
const self = {
|
|
@@ -339,5 +340,6 @@ exports.VIYA_HANDLERS = {
|
|
|
339
340
|
};
|
|
340
341
|
},
|
|
341
342
|
...compute_js_1.COMPUTE_HANDLERS,
|
|
342
|
-
...files_js_1.FILE_HANDLERS
|
|
343
|
+
...files_js_1.FILE_HANDLERS,
|
|
344
|
+
...identity_js_1.IDENTITY_HANDLERS
|
|
343
345
|
};
|
|
@@ -16,6 +16,7 @@ exports.estateFor = exports.EmulatedEstate = exports.logFor = void 0;
|
|
|
16
16
|
* that parses for NOTEs still gets a well-formed log, and a person reading it is
|
|
17
17
|
* not misled about what ran.
|
|
18
18
|
*/
|
|
19
|
+
const uuid_js_1 = require("../uuid.js");
|
|
19
20
|
const seed_js_1 = require("./seed.js");
|
|
20
21
|
/**
|
|
21
22
|
* The generated log for one program.
|
|
@@ -52,19 +53,24 @@ exports.logFor = logFor;
|
|
|
52
53
|
/**
|
|
53
54
|
* The sessions one estate holds.
|
|
54
55
|
*
|
|
55
|
-
* Keyed by
|
|
56
|
-
*
|
|
56
|
+
* Keyed by the estate's key - the full normalised address, not the seed it
|
|
57
|
+
* digests to - so two emulated estates in one process (a test that runs two
|
|
58
|
+
* targets, or two addresses whose 32-bit seeds collide) do not share a session
|
|
59
|
+
* namespace. See `estateKeyOf`.
|
|
57
60
|
*/
|
|
58
61
|
class EmulatedEstate {
|
|
59
62
|
constructor(seed) {
|
|
60
63
|
this.seed = seed;
|
|
61
64
|
this.sessions = new Map();
|
|
62
|
-
this.created = 0;
|
|
63
65
|
}
|
|
64
|
-
/** A new session:
|
|
65
|
-
create() {
|
|
66
|
+
/** A new session: opaque UUID v4, no jobs. */
|
|
67
|
+
create(owner) {
|
|
68
|
+
const id = (0, uuid_js_1.newUuidV4)();
|
|
69
|
+
if (this.sessions.has(id))
|
|
70
|
+
throw new Error('Duplicate compute session ID.');
|
|
66
71
|
const session = {
|
|
67
|
-
id
|
|
72
|
+
id,
|
|
73
|
+
owner,
|
|
68
74
|
createdAt: new Date().toISOString(),
|
|
69
75
|
jobs: new Map(),
|
|
70
76
|
submitted: 0
|
|
@@ -102,14 +108,22 @@ class EmulatedEstate {
|
|
|
102
108
|
}
|
|
103
109
|
}
|
|
104
110
|
exports.EmulatedEstate = EmulatedEstate;
|
|
105
|
-
/** One estate per
|
|
111
|
+
/** One estate per address, for the life of the process. */
|
|
106
112
|
const estates = new Map();
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
/**
|
|
114
|
+
* The estate one address holds, minting it on first use.
|
|
115
|
+
*
|
|
116
|
+
* Keyed by the estate's key - the full normalised address - never by the seed:
|
|
117
|
+
* the seed is a 32-bit digest of the address, two distinct addresses collide on
|
|
118
|
+
* it, and a collision must not give them one shared session store. The estate
|
|
119
|
+
* still uses the seed for its generated logs.
|
|
120
|
+
*/
|
|
121
|
+
const estateFor = (key, seed) => {
|
|
122
|
+
const existing = estates.get(key);
|
|
109
123
|
if (existing)
|
|
110
124
|
return existing;
|
|
111
125
|
const estate = new EmulatedEstate(seed);
|
|
112
|
-
estates.set(
|
|
126
|
+
estates.set(key, estate);
|
|
113
127
|
return estate;
|
|
114
128
|
};
|
|
115
129
|
exports.estateFor = estateFor;
|
|
@@ -13,15 +13,7 @@
|
|
|
13
13
|
* is the key: what the registry, the routes and the permission rules point at.
|
|
14
14
|
*/
|
|
15
15
|
export declare const normaliseAppLoc: (appLoc: string) => string;
|
|
16
|
-
|
|
17
|
-
* A new id: a version 4 UUID.
|
|
18
|
-
*
|
|
19
|
-
* `crypto.randomUUID` exists in Node and in a browser worker on https or localhost,
|
|
20
|
-
* which is where the mock drive runs. The fallback builds the same thing from
|
|
21
|
-
* `getRandomValues` rather than from `Math.random`, so a weaker environment does not
|
|
22
|
-
* quietly produce a weaker id.
|
|
23
|
-
*/
|
|
24
|
-
export declare const newAppId: () => string;
|
|
16
|
+
export { newUuidV4 as newAppId } from '../uuid.js';
|
|
25
17
|
/** Whether a string is a well-formed id: a version 4 UUID. */
|
|
26
18
|
export declare const isAppId: (value: unknown) => value is string;
|
|
27
19
|
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/appstream/identity.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,MAgBhD,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/appstream/identity.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,MAgBhD,CAAA;AAED,OAAO,EAAE,SAAS,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAA;AAOlD,8DAA8D;AAC9D,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACD,CAAA"}
|
|
@@ -26,36 +26,7 @@ export const normaliseAppLoc = (appLoc) => {
|
|
|
26
26
|
throw new ApiError(400, 'appLoc cannot be outside drive.');
|
|
27
27
|
return normalised;
|
|
28
28
|
};
|
|
29
|
-
|
|
30
|
-
* A new id: a version 4 UUID.
|
|
31
|
-
*
|
|
32
|
-
* `crypto.randomUUID` exists in Node and in a browser worker on https or localhost,
|
|
33
|
-
* which is where the mock drive runs. The fallback builds the same thing from
|
|
34
|
-
* `getRandomValues` rather than from `Math.random`, so a weaker environment does not
|
|
35
|
-
* quietly produce a weaker id.
|
|
36
|
-
*/
|
|
37
|
-
export const newAppId = () => {
|
|
38
|
-
const webCrypto = globalThis.crypto;
|
|
39
|
-
if (typeof webCrypto?.randomUUID === 'function')
|
|
40
|
-
return webCrypto.randomUUID();
|
|
41
|
-
if (typeof webCrypto?.getRandomValues !== 'function')
|
|
42
|
-
throw new Error('No cryptographic source of randomness is available.');
|
|
43
|
-
const bytes = new Uint8Array(16);
|
|
44
|
-
webCrypto.getRandomValues(bytes);
|
|
45
|
-
// version 4, variant 10xx
|
|
46
|
-
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
47
|
-
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
48
|
-
const hex = Array.from(bytes)
|
|
49
|
-
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
50
|
-
.join('');
|
|
51
|
-
return [
|
|
52
|
-
hex.slice(0, 8),
|
|
53
|
-
hex.slice(8, 12),
|
|
54
|
-
hex.slice(12, 16),
|
|
55
|
-
hex.slice(16, 20),
|
|
56
|
-
hex.slice(20)
|
|
57
|
-
].join('-');
|
|
58
|
-
};
|
|
29
|
+
export { newUuidV4 as newAppId } from '../uuid.js';
|
|
59
30
|
// no `i` flag: `newAppId` mints lower case and every lookup compares exactly, so
|
|
60
31
|
// a guard that accepts upper case would vouch for an id no lookup can find
|
|
61
32
|
const APP_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts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AAA;IAChB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,qEAAqE;AACrE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/uuid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAO,MAkC5B,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A UUID v4 for Node and browser workers. Where `randomUUID` is unavailable,
|
|
3
|
+
* build it from `getRandomValues`; do not fall back to weaker randomness.
|
|
4
|
+
*/
|
|
5
|
+
export const newUuidV4 = () => {
|
|
6
|
+
const webCrypto = globalThis.crypto;
|
|
7
|
+
if (typeof webCrypto?.randomUUID === 'function')
|
|
8
|
+
return webCrypto.randomUUID();
|
|
9
|
+
if (typeof webCrypto?.getRandomValues !== 'function')
|
|
10
|
+
throw new Error('No cryptographic source of randomness is available.');
|
|
11
|
+
const bytes = new Uint8Array(16);
|
|
12
|
+
webCrypto.getRandomValues(bytes);
|
|
13
|
+
// version 4, variant 10xx
|
|
14
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
15
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
16
|
+
const hex = Array.from(bytes)
|
|
17
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
18
|
+
.join('');
|
|
19
|
+
return [
|
|
20
|
+
hex.slice(0, 8),
|
|
21
|
+
hex.slice(8, 12),
|
|
22
|
+
hex.slice(12, 16),
|
|
23
|
+
hex.slice(16, 20),
|
|
24
|
+
hex.slice(20)
|
|
25
|
+
].join('-');
|
|
26
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The application's call surface, and what this package decides about each entry.
|
|
3
|
+
*
|
|
4
|
+
* `src/viya/surface.ts` is the adapter's surface: what `@sasjs/adapter` measured
|
|
5
|
+
* to build. It is not the whole story, because an application can call the
|
|
6
|
+
* platform itself. Data Controller does exactly that - its group, user and deploy
|
|
7
|
+
* screens speak Viya REST directly for the calls the adapter does not offer -
|
|
8
|
+
* and the emulator answered those paths with the 404 that says "the emulated
|
|
9
|
+
* estate answers the client's call surface and nothing else". A capture pass
|
|
10
|
+
* driven by the adapter can never see them, so they were outside a scope that
|
|
11
|
+
* was measured from the adapter alone, and the screens they carry were dead on
|
|
12
|
+
* an emulated estate.
|
|
13
|
+
*
|
|
14
|
+
* This file is the second measurement. `spec/viya/app-paths.json` is what Data
|
|
15
|
+
* Controller's client was measured to build (`scripts/viya-app-scope.mjs` re-runs
|
|
16
|
+
* the extraction from a checkout), and every path in it is classified here. The
|
|
17
|
+
* two are held together in both directions, the way the adapter's inventory and
|
|
18
|
+
* `surface.ts` are: a path nobody classified is scope creep nobody chose, and a
|
|
19
|
+
* classification for a path the application no longer builds is a stale claim
|
|
20
|
+
* about what a host has to answer.
|
|
21
|
+
*
|
|
22
|
+
* `decision: 'in'` means a host must answer it. That is a promise the table keeps
|
|
23
|
+
* - `spec/viyaTable.spec.ts` refuses an answered operation no in-scope entry
|
|
24
|
+
* covers - so an `in` entry with no operation is a gap the table spec does not
|
|
25
|
+
* catch. Read the two together: `src/viya/declared.ts` is where an `in` path
|
|
26
|
+
* becomes an operation.
|
|
27
|
+
*/
|
|
28
|
+
import type { SurfaceFamily } from './surface.js';
|
|
29
|
+
export interface AppSurfaceEntry {
|
|
30
|
+
/** Where the application sends it; `{}` is one path segment. */
|
|
31
|
+
path: string;
|
|
32
|
+
family: SurfaceFamily;
|
|
33
|
+
decision: 'in' | 'declined';
|
|
34
|
+
/** What the emulator answers, or why it does not answer this at all. */
|
|
35
|
+
reason: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The application the inventory was measured from.
|
|
39
|
+
*
|
|
40
|
+
* Named rather than assumed: the inventory describes one application's calls,
|
|
41
|
+
* and a second application running on an emulated estate is a second inventory -
|
|
42
|
+
* not an edit to this one, whose rows would then be a claim about a client
|
|
43
|
+
* nobody measured.
|
|
44
|
+
*/
|
|
45
|
+
export declare const APP_SURFACE_APPLICATION: {
|
|
46
|
+
name: string;
|
|
47
|
+
repository: string;
|
|
48
|
+
measuredFrom: string;
|
|
49
|
+
};
|
|
50
|
+
export declare const APP_SURFACE: AppSurfaceEntry[];
|
|
51
|
+
//# sourceMappingURL=appSurface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appSurface.d.ts","sourceRoot":"","sources":["../../../src/viya/appSurface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,aAAa,CAAA;IACrB,QAAQ,EAAE,IAAI,GAAG,UAAU,CAAA;IAC3B,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB;;;;CAInC,CAAA;AAMD,eAAO,MAAM,WAAW,EAAE,eAAe,EAkPxC,CAAA"}
|