@cratis/chronicle 6.68.0 → 6.69.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.
Files changed (45) hide show
  1. package/dist/externalServices/ExternalServiceBuilder.d.ts +1 -1
  2. package/dist/externalServices/ExternalServiceBuilder.d.ts.map +1 -1
  3. package/dist/externalServices/ExternalServiceBuilder.js +2 -2
  4. package/dist/externalServices/ExternalServiceBuilder.js.map +1 -1
  5. package/dist/externalServices/IExternalServiceBuilder.d.ts +2 -1
  6. package/dist/externalServices/IExternalServiceBuilder.d.ts.map +1 -1
  7. package/dist/externalServices/for_ExternalServices/given/an_external_service_registration.d.ts +8 -0
  8. package/dist/externalServices/for_ExternalServices/given/an_external_service_registration.d.ts.map +1 -0
  9. package/dist/externalServices/for_ExternalServices/given/an_external_service_registration.js +20 -0
  10. package/dist/externalServices/for_ExternalServices/given/an_external_service_registration.js.map +1 -0
  11. package/dist/testing/ConstraintKey.d.ts.map +1 -1
  12. package/dist/testing/ConstraintKey.js +11 -6
  13. package/dist/testing/ConstraintKey.js.map +1 -1
  14. package/dist/testing/MeasuredCaseFolding.d.ts +14 -0
  15. package/dist/testing/MeasuredCaseFolding.d.ts.map +1 -0
  16. package/dist/testing/MeasuredCaseFolding.js +17 -0
  17. package/dist/testing/MeasuredCaseFolding.js.map +1 -0
  18. package/dist/tsconfig.tsbuildinfo +1 -1
  19. package/dist/webhooks/IWebhookDefinitionBuilder.d.ts +2 -1
  20. package/dist/webhooks/IWebhookDefinitionBuilder.d.ts.map +1 -1
  21. package/dist/webhooks/WebhookDefinitionBuilder.d.ts +1 -1
  22. package/dist/webhooks/WebhookDefinitionBuilder.d.ts.map +1 -1
  23. package/dist/webhooks/WebhookDefinitionBuilder.js +2 -2
  24. package/dist/webhooks/WebhookDefinitionBuilder.js.map +1 -1
  25. package/dist/webhooks/for_Webhooks/given/a_webhook_registration.d.ts +8 -0
  26. package/dist/webhooks/for_Webhooks/given/a_webhook_registration.d.ts.map +1 -0
  27. package/dist/webhooks/for_Webhooks/given/a_webhook_registration.js +20 -0
  28. package/dist/webhooks/for_Webhooks/given/a_webhook_registration.js.map +1 -0
  29. package/externalServices/ExternalServiceBuilder.ts +2 -2
  30. package/externalServices/IExternalServiceBuilder.ts +2 -1
  31. package/externalServices/for_ExternalServices/given/an_external_service_registration.ts +23 -0
  32. package/externalServices/for_ExternalServices/when_registering_with_an_oauth_scope.spec.ts +42 -0
  33. package/externalServices/for_ExternalServices/when_registering_without_an_oauth_scope.spec.ts +44 -0
  34. package/package.json +1 -1
  35. package/testing/ConstraintKey.ts +11 -7
  36. package/testing/EventScenario.fixtures.spec.ts +1 -1
  37. package/testing/MeasuredCaseFolding.ts +22 -0
  38. package/testing/for_EventScenario/when_appending_case_folded_text/case_folded_text.fixture.ts +160 -0
  39. package/testing/for_EventScenario/when_appending_case_folded_text/with_case_folded_text.legacy.spec.ts +14 -0
  40. package/testing/for_EventScenario/when_appending_case_folded_text/with_case_folded_text.standard.spec.ts +13 -0
  41. package/webhooks/IWebhookDefinitionBuilder.ts +2 -1
  42. package/webhooks/WebhookDefinitionBuilder.ts +2 -2
  43. package/webhooks/for_Webhooks/given/a_webhook_registration.ts +25 -0
  44. package/webhooks/for_Webhooks/when_registering_with_an_oauth_scope.spec.ts +42 -0
  45. package/webhooks/for_Webhooks/when_registering_without_an_oauth_scope.spec.ts +43 -0
@@ -0,0 +1,43 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { AddWebhooksRequest, OAuthAuthorization } from '@cratis/chronicle.contracts';
5
+ import { beforeEach, chai, describe, it } from 'vitest';
6
+ import { a_webhook_registration } from './given/a_webhook_registration.js';
7
+
8
+ chai.should();
9
+
10
+ describe.each([
11
+ { condition: 'omitted', scope: undefined },
12
+ { condition: 'empty', scope: '' },
13
+ { condition: 'undefined', scope: undefined },
14
+ { condition: 'null at runtime', scope: null as unknown as string }
15
+ ])('when registering a webhook with $condition OAuth scope', ({ condition, scope }) => {
16
+ let context: a_webhook_registration;
17
+ let oauth: OAuthAuthorization;
18
+ let request: AddWebhooksRequest;
19
+
20
+ beforeEach(async () => {
21
+ context = new a_webhook_registration();
22
+ await context.webhooks.register('orders', 'https://example.test/webhook', builder => {
23
+ const configured = condition === 'omitted'
24
+ ? builder.withOAuth('https://auth.example.test', 'fake-client', 'fake-secret')
25
+ : builder.withOAuth('https://auth.example.test', 'fake-client', 'fake-secret', scope);
26
+ configured.withHeader('x-source', 'fake-app');
27
+ });
28
+ request = AddWebhooksRequest.decode(AddWebhooksRequest.encode(context.sent).finish());
29
+ oauth = request.Webhooks[0].Target!.Authorization!.Value2!;
30
+ });
31
+
32
+ it('should normalize scope before encoding', () => context.sent.Webhooks[0].Target!.Authorization!.Value2!.Scope.should.equal(''));
33
+ it('should select OAuth authorization', () => chai.expect(oauth).not.to.be.undefined);
34
+ it('should leave basic authorization unset', () => chai.expect(request.Webhooks[0].Target!.Authorization!.Value0).to.be.undefined);
35
+ it('should leave bearer authorization unset', () => chai.expect(request.Webhooks[0].Target!.Authorization!.Value1).to.be.undefined);
36
+ it('should preserve credentials and default scope through the request codec', () => oauth.should.deep.equal({
37
+ Authority: 'https://auth.example.test', ClientId: 'fake-client', ClientSecret: 'fake-secret', Scope: ''
38
+ }));
39
+ it('should retain chained headers', () => request.Webhooks[0].Target!.Headers['x-source'].should.equal('fake-app'));
40
+ it('should omit the default scope field from the wire', () => OAuthAuthorization.encode({
41
+ ...oauth, Authority: '', ClientId: '', ClientSecret: ''
42
+ }).finish().should.deep.equal(new Uint8Array()));
43
+ });