@balena/open-balena-api 31.2.9-build-resolve-dsev-permission-with-device-2dc23ee89aaea920572df3ffabc06fa8fe5770e8-1 → 31.3.0-build-add-target-os-release-changed-sv-update-hook-7c78b17a31253a0faf8f3013414215b6aa5f25ab-1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,9 +8,11 @@ hooks.addPureHook('PATCH', 'resin', 'device', {
8
8
  // * app changed
9
9
  // * target release changed
10
10
  // * device name changed - so a user can restart their service and it will pick up the change
11
+ // * target OS release changed, so that Supervisors that support this can trigger a HUP
11
12
  if ((request.values.is_pinned_on__release !== undefined ||
12
13
  request.values.belongs_to__application != null ||
13
- request.values.device_name != null) &&
14
+ request.values.device_name != null ||
15
+ request.values.should_be_operated_by__release != null) &&
14
16
  affectedIds.length !== 0) {
15
17
  // Send the update requests only after the tx is committed
16
18
  tx.on('end', async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"device-update-trigger.js","sourceRoot":"","sources":["../../../../src/features/ci-cd/hooks/device-update-trigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE;IAC7C,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE;QAC5B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAY,CAAC;QAEzC,yCAAyC;QACzC,gBAAgB;QAChB,2BAA2B;QAC3B,6FAA6F;QAC7F,IACC,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAqB,KAAK,SAAS;YAClD,OAAO,CAAC,MAAM,CAAC,uBAAuB,IAAI,IAAI;YAC9C,OAAO,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC;YACpC,WAAW,CAAC,MAAM,KAAK,CAAC,EACvB,CAAC;YACF,0DAA0D;YAC1D,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;gBACvB,IAAI,CAAC;oBACJ,MAAM,WAAW,CAAC;wBACjB,GAAG,EAAE,YAAY;wBACjB,GAAG,EAAE,WAAW,CAAC,IAAI;wBACrB,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;wBACpC,IAAI,EAAE,KAAK;qBACX,CAAC,CAAC;gBACJ,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACd,gBAAgB,CAAC,GAAG,EAAE,gCAAgC,CAAC,CAAC;gBACzD,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
1
+ {"version":3,"file":"device-update-trigger.js","sourceRoot":"","sources":["../../../../src/features/ci-cd/hooks/device-update-trigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEjE,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE;IAC7C,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE;QAC5B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAY,CAAC;QAEzC,yCAAyC;QACzC,gBAAgB;QAChB,2BAA2B;QAC3B,6FAA6F;QAC7F,uFAAuF;QACvF,IACC,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAqB,KAAK,SAAS;YAClD,OAAO,CAAC,MAAM,CAAC,uBAAuB,IAAI,IAAI;YAC9C,OAAO,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI;YAClC,OAAO,CAAC,MAAM,CAAC,8BAA8B,IAAI,IAAI,CAAC;YACvD,WAAW,CAAC,MAAM,KAAK,CAAC,EACvB,CAAC;YACF,0DAA0D;YAC1D,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;gBACvB,IAAI,CAAC;oBACJ,MAAM,WAAW,CAAC;wBACjB,GAAG,EAAE,YAAY;wBACjB,GAAG,EAAE,WAAW,CAAC,IAAI;wBACrB,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;wBACpC,IAAI,EAAE,KAAK;qBACX,CAAC,CAAC;gBACJ,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACd,gBAAgB,CAAC,GAAG,EAAE,gCAAgC,CAAC,CAAC;gBACzD,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { hooks, errors } from '@balena/pinejs';
2
+ async function backfillDeviceAndService({ request, api, }) {
3
+ const { service_install: siId } = request.values;
4
+ if (siId == null) {
5
+ return;
6
+ }
7
+ const si = await api.get({
8
+ resource: 'service_install',
9
+ id: siId,
10
+ options: {
11
+ $select: ['device', 'service'],
12
+ },
13
+ });
14
+ if (si == null) {
15
+ throw new errors.UnauthorizedError();
16
+ }
17
+ request.values.device = si.device.__id;
18
+ request.values.service = si.service.__id;
19
+ }
20
+ hooks.addPureHook('POST', 'resin', 'device_service_environment_variable', {
21
+ POSTPARSE: backfillDeviceAndService,
22
+ });
23
+ hooks.addPureHook('PATCH', 'resin', 'device_service_environment_variable', {
24
+ POSTPARSE: backfillDeviceAndService,
25
+ });
26
+ //# sourceMappingURL=backfill-device-service-environment-variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backfill-device-service-environment-variable.js","sourceRoot":"","sources":["../../../../src/features/service-install/hooks/backfill-device-service-environment-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,gBAAgB,CAAC;AAE/D,KAAK,UAAU,wBAAwB,CAAC,EACvC,OAAO,EACP,GAAG,GAC0B;IAC7B,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAEjD,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO;IACR,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC;QACxB,QAAQ,EAAE,iBAAiB;QAC3B,EAAE,EAAE,IAAI;QACR,OAAO,EAAE;YACR,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;SAC9B;KACD,CAAC,CAAC;IAEH,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;IACtC,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;IACvC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;AAC1C,CAAC;AAED,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,qCAAqC,EAAE;IACzE,SAAS,EAAE,wBAAwB;CACnC,CAAC,CAAC;AAEH,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,qCAAqC,EAAE;IAC1E,SAAS,EAAE,wBAAwB;CACnC,CAAC,CAAC"}
@@ -1 +1 @@
1
- import './backfill-service-install-on-device-service-env-var.js';
1
+ import './backfill-device-service-environment-variable.js';
@@ -1,2 +1,2 @@
1
- import './backfill-service-install-on-device-service-env-var.js';
1
+ import './backfill-device-service-environment-variable.js';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/service-install/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yDAAyD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/features/service-install/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,mDAAmD,CAAC"}
package/dist/lib/auth.js CHANGED
@@ -81,8 +81,8 @@ export const DEVICE_API_KEY_PERMISSIONS = [
81
81
  // A device should be able to manage its own service installs, even from apps its not or no longer part of (past/supervisor/os)
82
82
  ...writePerms('resin.service_install', `device/any(d:${matchesNonFrozenDeviceActor('d')})`, ['update', 'delete']),
83
83
  'resin.service_environment_variable.read?service/canAccess()',
84
- 'resin.device_service_environment_variable.read?device/canAccess()',
85
- ...writePerms('resin.device_service_environment_variable', `device/any(d:${matchesNonFrozenDeviceActor('d')})`),
84
+ 'resin.device_service_environment_variable.read?service_install/canAccess()',
85
+ ...writePerms('resin.device_service_environment_variable', `service_install/any(si:si/device/any(d:${matchesNonFrozenDeviceActor('d')}))`),
86
86
  'resin.image__is_part_of__release.read?is_part_of__release/canAccess()',
87
87
  'resin.image.read?image_install/canAccess() or image__is_part_of__release/canAccess()',
88
88
  'resin.image_install.read?device/canAccess()',
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,8DAA8D;AAC9D,EAAE;AAIF,OAAO,EACN,uBAAuB,EACvB,gCAAgC,EAChC,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,aAAa,CAAC;AAErB,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAElE,MAAM,UAAU,GAAG,CAClB,QAAgB,EAChB,MAAc,EACd,SAA4D,iBAAiB,EAClE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,QAAQ,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC,CAAC;AAErE,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAC5C,MAAM,WAAW,GAAG,gBAAgB,YAAY,GAAG,CAAC;AACpD,MAAM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,CACxD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAC/B,CAAC;IACF,IAAI,WAAW,EAAE,CAAC;QACjB,OAAO,WAAW,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;AACF,CAAC,CAAC"}
@@ -1,32 +1,2 @@
1
- import { hooks, sbvrUtils, errors } from '@balena/pinejs';
2
- const addReadOnlyHook = (methods, resource, hook) => {
3
- methods.map((method) => {
4
- hooks.addHook(method, 'v7', resource, {
5
- ...hook,
6
- sideEffects: false,
7
- readOnlyTx: true,
8
- });
9
- });
10
- };
11
- addReadOnlyHook(['POST', 'PATCH', 'PUT'], 'device_service_environment_variable', {
12
- POSTPARSE: async ({ request, api }) => {
13
- const { service_install: siId } = request.values;
14
- if (siId == null) {
15
- return;
16
- }
17
- const si = await sbvrUtils.api.resin.get({
18
- resource: 'service_install',
19
- passthrough: api.passthrough,
20
- id: siId,
21
- options: {
22
- $select: ['device', 'service'],
23
- },
24
- });
25
- if (si == null) {
26
- throw new errors.UnauthorizedError();
27
- }
28
- request.values.device = si.device.__id;
29
- request.values.service = si.service.__id;
30
- },
31
- });
1
+ export {};
32
2
  //# sourceMappingURL=hooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/translations/v7/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,eAAe,GAAG,CACvB,OAAmD,EACnD,QAAgB,EAChB,IAA2B,EAC1B,EAAE;IACH,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACtB,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;YACrC,GAAG,IAAI;YACP,WAAW,EAAE,KAAK;YAClB,UAAU,EAAE,IAAI;SAChB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,CACd,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EACxB,qCAAqC,EACrC;IACC,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE;QACrC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QAEjD,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO;QACR,CAAC;QAED,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;YACxC,QAAQ,EAAE,iBAAiB;YAC3B,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,EAAE,EAAE,IAAI;YACR,OAAO,EAAE;gBACR,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;aAC9B;SACD,CAAC,CAAC;QAEH,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;YAChB,MAAM,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACtC,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;QACvC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1C,CAAC;CACD,CACD,CAAC"}
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/translations/v7/hooks.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@balena/open-balena-api",
3
3
  "description": "Internet of things, Made Simple",
4
- "version": "31.2.9-build-resolve-dsev-permission-with-device-2dc23ee89aaea920572df3ffabc06fa8fe5770e8-1",
4
+ "version": "31.3.0-build-add-target-os-release-changed-sv-update-hook-7c78b17a31253a0faf8f3013414215b6aa5f25ab-1",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -166,6 +166,6 @@
166
166
  "loader": "ts-node/esm/transpile-only"
167
167
  },
168
168
  "versionist": {
169
- "publishedAt": "2024-11-19T23:57:47.310Z"
169
+ "publishedAt": "2024-11-20T08:01:36.754Z"
170
170
  }
171
171
  }
@@ -1,41 +0,0 @@
1
- import { hooks, errors } from '@balena/pinejs';
2
- async function backfillServiceInstall({ request, api, }) {
3
- const { device: deviceId, service: serviceId } = request.values;
4
- if (deviceId == null && serviceId == null) {
5
- return;
6
- }
7
- if ((deviceId == null && serviceId != null) ||
8
- (deviceId != null && serviceId == null)) {
9
- throw new errors.BadRequestError('Both or none of device and service must be specified');
10
- }
11
- let si = await api.get({
12
- resource: 'service_install',
13
- id: {
14
- device: deviceId,
15
- installs__service: serviceId,
16
- },
17
- options: {
18
- $select: ['id'],
19
- },
20
- });
21
- if (si == null) {
22
- si = await api.post({
23
- resource: 'service_install',
24
- body: {
25
- device: deviceId,
26
- installs__service: serviceId,
27
- },
28
- });
29
- }
30
- if (si == null) {
31
- throw new errors.BadRequestError(`No service install exists for device: ${deviceId} and service ${serviceId} and one could not be created`);
32
- }
33
- request.values.service_install = si.id;
34
- }
35
- hooks.addPureHook('POST', 'resin', 'device_service_environment_variable', {
36
- POSTPARSE: backfillServiceInstall,
37
- });
38
- hooks.addPureHook('PATCH', 'resin', 'device_service_environment_variable', {
39
- POSTPARSE: backfillServiceInstall,
40
- });
41
- //# sourceMappingURL=backfill-service-install-on-device-service-env-var.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"backfill-service-install-on-device-service-env-var.js","sourceRoot":"","sources":["../../../../src/features/service-install/hooks/backfill-service-install-on-device-service-env-var.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,gBAAgB,CAAC;AAE/D,KAAK,UAAU,sBAAsB,CAAC,EACrC,OAAO,EACP,GAAG,GAC0B;IAC7B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,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