@openfn/language-inji 0.0.0-stage → 1.0.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.
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "properties": {
4
+ "baseUrl": {
5
+ "title": "Base URL",
6
+ "type": "string",
7
+ "description": "Inji Verify service base URL, including the context path /v1/verify",
8
+ "format": "uri",
9
+ "minLength": 1,
10
+ "examples": ["https://verify.example.org/v1/verify"]
11
+ }
12
+ },
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["baseUrl"]
16
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,183 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.js
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ as: () => import_language_common2.as,
23
+ combine: () => import_language_common2.combine,
24
+ cursor: () => import_language_common2.cursor,
25
+ dataPath: () => import_language_common2.dataPath,
26
+ dataValue: () => import_language_common2.dataValue,
27
+ dateFns: () => import_language_common2.dateFns,
28
+ default: () => src_default,
29
+ each: () => import_language_common2.each,
30
+ field: () => import_language_common2.field,
31
+ fields: () => import_language_common2.fields,
32
+ fn: () => import_language_common2.fn,
33
+ fnIf: () => import_language_common2.fnIf,
34
+ group: () => import_language_common2.group,
35
+ lastReferenceValue: () => import_language_common2.lastReferenceValue,
36
+ map: () => import_language_common2.map,
37
+ merge: () => import_language_common2.merge,
38
+ request: () => request2,
39
+ scrubEmojis: () => import_language_common2.scrubEmojis,
40
+ sourceValue: () => import_language_common2.sourceValue,
41
+ util: () => import_language_common2.util,
42
+ verify: () => verify
43
+ });
44
+ module.exports = __toCommonJS(src_exports);
45
+
46
+ // src/Adaptor.js
47
+ var Adaptor_exports = {};
48
+ __export(Adaptor_exports, {
49
+ as: () => import_language_common2.as,
50
+ combine: () => import_language_common2.combine,
51
+ cursor: () => import_language_common2.cursor,
52
+ dataPath: () => import_language_common2.dataPath,
53
+ dataValue: () => import_language_common2.dataValue,
54
+ dateFns: () => import_language_common2.dateFns,
55
+ each: () => import_language_common2.each,
56
+ field: () => import_language_common2.field,
57
+ fields: () => import_language_common2.fields,
58
+ fn: () => import_language_common2.fn,
59
+ fnIf: () => import_language_common2.fnIf,
60
+ group: () => import_language_common2.group,
61
+ lastReferenceValue: () => import_language_common2.lastReferenceValue,
62
+ map: () => import_language_common2.map,
63
+ merge: () => import_language_common2.merge,
64
+ request: () => request2,
65
+ scrubEmojis: () => import_language_common2.scrubEmojis,
66
+ sourceValue: () => import_language_common2.sourceValue,
67
+ util: () => import_language_common2.util,
68
+ verify: () => verify
69
+ });
70
+ var import_util2 = require("@openfn/language-common/util");
71
+
72
+ // src/Utils.js
73
+ var import_language_common = require("@openfn/language-common");
74
+ var import_util = require("@openfn/language-common/util");
75
+ var prepareNextState = (state, response) => {
76
+ const { body, ...responseWithoutBody } = response;
77
+ if (!state.references) {
78
+ state.references = [];
79
+ }
80
+ return {
81
+ ...(0, import_language_common.composeNextState)(state, response.body),
82
+ response: responseWithoutBody
83
+ };
84
+ };
85
+ var toVerifiableCredential = (credential) => {
86
+ if (credential == null) {
87
+ throw new Error("A verifiable credential is required");
88
+ }
89
+ if (typeof credential === "string") {
90
+ return credential;
91
+ }
92
+ return JSON.stringify(credential);
93
+ };
94
+ var request = (configuration = {}, method, path, options = {}) => {
95
+ const { baseUrl } = configuration;
96
+ const { headers = {}, ...rest } = options;
97
+ const errors = {
98
+ 400: "Invalid verification request payload",
99
+ 500: "Inji Verify verification or status-list check failed"
100
+ };
101
+ const opts = {
102
+ parseAs: "json",
103
+ errors,
104
+ baseUrl,
105
+ ...rest,
106
+ headers: {
107
+ "content-type": "application/json",
108
+ ...headers
109
+ }
110
+ };
111
+ return (0, import_util.request)(method, path, opts);
112
+ };
113
+
114
+ // src/Adaptor.js
115
+ var import_language_common2 = require("@openfn/language-common");
116
+ function verify(credential, options = {}) {
117
+ return async (state) => {
118
+ const [resolvedCredential, resolvedOptions] = (0, import_util2.expandReferences)(
119
+ state,
120
+ credential,
121
+ options
122
+ );
123
+ const {
124
+ skipStatusChecks = false,
125
+ statusCheckFilters = [],
126
+ includeClaims = false
127
+ } = resolvedOptions;
128
+ const body = {
129
+ verifiableCredential: toVerifiableCredential(resolvedCredential),
130
+ skipStatusChecks,
131
+ statusCheckFilters,
132
+ includeClaims
133
+ };
134
+ const response = await request(
135
+ state.configuration,
136
+ "POST",
137
+ "v2/vc-verification",
138
+ { body }
139
+ );
140
+ return prepareNextState(state, response);
141
+ };
142
+ }
143
+ function request2(method, path, body, options = {}) {
144
+ return async (state) => {
145
+ const [resolvedMethod, resolvedPath, resolvedBody, resolvedOptions] = (0, import_util2.expandReferences)(state, method, path, body, options);
146
+ const response = await request(
147
+ state.configuration,
148
+ resolvedMethod,
149
+ resolvedPath,
150
+ {
151
+ body: resolvedBody,
152
+ ...resolvedOptions
153
+ }
154
+ );
155
+ return prepareNextState(state, response);
156
+ };
157
+ }
158
+
159
+ // src/index.js
160
+ var src_default = Adaptor_exports;
161
+ // Annotate the CommonJS export names for ESM import in node:
162
+ 0 && (module.exports = {
163
+ as,
164
+ combine,
165
+ cursor,
166
+ dataPath,
167
+ dataValue,
168
+ dateFns,
169
+ each,
170
+ field,
171
+ fields,
172
+ fn,
173
+ fnIf,
174
+ group,
175
+ lastReferenceValue,
176
+ map,
177
+ merge,
178
+ request,
179
+ scrubEmojis,
180
+ sourceValue,
181
+ util,
182
+ verify
183
+ });
package/dist/index.js ADDED
@@ -0,0 +1,163 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/Adaptor.js
8
+ var Adaptor_exports = {};
9
+ __export(Adaptor_exports, {
10
+ as: () => as,
11
+ combine: () => combine,
12
+ cursor: () => cursor,
13
+ dataPath: () => dataPath,
14
+ dataValue: () => dataValue,
15
+ dateFns: () => dateFns,
16
+ each: () => each,
17
+ field: () => field,
18
+ fields: () => fields,
19
+ fn: () => fn,
20
+ fnIf: () => fnIf,
21
+ group: () => group,
22
+ lastReferenceValue: () => lastReferenceValue,
23
+ map: () => map,
24
+ merge: () => merge,
25
+ request: () => request2,
26
+ scrubEmojis: () => scrubEmojis,
27
+ sourceValue: () => sourceValue,
28
+ util: () => util,
29
+ verify: () => verify
30
+ });
31
+ import { expandReferences } from "@openfn/language-common/util";
32
+
33
+ // src/Utils.js
34
+ import { composeNextState } from "@openfn/language-common";
35
+ import { request as commonRequest } from "@openfn/language-common/util";
36
+ var prepareNextState = (state, response) => {
37
+ const { body, ...responseWithoutBody } = response;
38
+ if (!state.references) {
39
+ state.references = [];
40
+ }
41
+ return {
42
+ ...composeNextState(state, response.body),
43
+ response: responseWithoutBody
44
+ };
45
+ };
46
+ var toVerifiableCredential = (credential) => {
47
+ if (credential == null) {
48
+ throw new Error("A verifiable credential is required");
49
+ }
50
+ if (typeof credential === "string") {
51
+ return credential;
52
+ }
53
+ return JSON.stringify(credential);
54
+ };
55
+ var request = (configuration = {}, method, path, options = {}) => {
56
+ const { baseUrl } = configuration;
57
+ const { headers = {}, ...rest } = options;
58
+ const errors = {
59
+ 400: "Invalid verification request payload",
60
+ 500: "Inji Verify verification or status-list check failed"
61
+ };
62
+ const opts = {
63
+ parseAs: "json",
64
+ errors,
65
+ baseUrl,
66
+ ...rest,
67
+ headers: {
68
+ "content-type": "application/json",
69
+ ...headers
70
+ }
71
+ };
72
+ return commonRequest(method, path, opts);
73
+ };
74
+
75
+ // src/Adaptor.js
76
+ import {
77
+ as,
78
+ combine,
79
+ cursor,
80
+ dataPath,
81
+ dataValue,
82
+ dateFns,
83
+ each,
84
+ field,
85
+ fields,
86
+ fn,
87
+ fnIf,
88
+ group,
89
+ lastReferenceValue,
90
+ map,
91
+ merge,
92
+ scrubEmojis,
93
+ sourceValue,
94
+ util
95
+ } from "@openfn/language-common";
96
+ function verify(credential, options = {}) {
97
+ return async (state) => {
98
+ const [resolvedCredential, resolvedOptions] = expandReferences(
99
+ state,
100
+ credential,
101
+ options
102
+ );
103
+ const {
104
+ skipStatusChecks = false,
105
+ statusCheckFilters = [],
106
+ includeClaims = false
107
+ } = resolvedOptions;
108
+ const body = {
109
+ verifiableCredential: toVerifiableCredential(resolvedCredential),
110
+ skipStatusChecks,
111
+ statusCheckFilters,
112
+ includeClaims
113
+ };
114
+ const response = await request(
115
+ state.configuration,
116
+ "POST",
117
+ "v2/vc-verification",
118
+ { body }
119
+ );
120
+ return prepareNextState(state, response);
121
+ };
122
+ }
123
+ function request2(method, path, body, options = {}) {
124
+ return async (state) => {
125
+ const [resolvedMethod, resolvedPath, resolvedBody, resolvedOptions] = expandReferences(state, method, path, body, options);
126
+ const response = await request(
127
+ state.configuration,
128
+ resolvedMethod,
129
+ resolvedPath,
130
+ {
131
+ body: resolvedBody,
132
+ ...resolvedOptions
133
+ }
134
+ );
135
+ return prepareNextState(state, response);
136
+ };
137
+ }
138
+
139
+ // src/index.js
140
+ var src_default = Adaptor_exports;
141
+ export {
142
+ as,
143
+ combine,
144
+ cursor,
145
+ dataPath,
146
+ dataValue,
147
+ dateFns,
148
+ src_default as default,
149
+ each,
150
+ field,
151
+ fields,
152
+ fn,
153
+ fnIf,
154
+ group,
155
+ lastReferenceValue,
156
+ map,
157
+ merge,
158
+ request2 as request,
159
+ scrubEmojis,
160
+ sourceValue,
161
+ util,
162
+ verify
163
+ };
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@openfn/language-inji",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "OpenFn Inji Verify adaptor",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "types": "./types/index.d.ts",
10
+ "require": "./dist/index.cjs"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "author": "Open Function Group",
15
+ "license": "LGPLv3",
16
+ "files": [
17
+ "dist/",
18
+ "types/",
19
+ "ast.json",
20
+ "configuration-schema.json"
21
+ ],
22
+ "dependencies": {
23
+ "@openfn/language-common": "3.3.5"
24
+ },
25
+ "devDependencies": {
26
+ "assertion-error": "2.0.0",
27
+ "chai": "4.3.6",
28
+ "deep-eql": "4.1.1",
29
+ "rimraf": "3.0.2",
30
+ "undici": "^7.19.2"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/OpenFn/adaptors.git"
35
+ },
36
+ "types": "types/index.d.ts",
37
+ "main": "dist/index.cjs",
38
+ "scripts": {
39
+ "build": "pnpm clean && build-adaptor inji",
40
+ "test": "mocha --experimental-specifier-resolution=node --no-warnings",
41
+ "test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
42
+ "clean": "rimraf dist types docs",
43
+ "pack": "pnpm pack --pack-destination ../../dist",
44
+ "lint": "eslint src"
45
+ }
6
46
  }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * State object after an Inji Verify HTTP call
3
+ * @typedef {Object} HttpState
4
+ * @property data - the parsed response body
5
+ * @property response - the response from the HTTP server, including headers, statusCode, etc
6
+ * @property references - an array of all previous data objects used in the Job
7
+ **/
8
+ /**
9
+ * Options for verify
10
+ * @typedef {Object} VerifyOptions
11
+ * @public
12
+ * @property {boolean} [skipStatusChecks=false] - Skip credential status (e.g. revocation) checks
13
+ * @property {string[]} [statusCheckFilters=[]] - Status check purposes to run (e.g. `['revocation']`)
14
+ * @property {boolean} [includeClaims=false] - Include extracted claims when schema/signature is valid
15
+ */
16
+ /**
17
+ * Options provided to a general HTTP request
18
+ * @typedef {Object} RequestOptions
19
+ * @public
20
+ * @property {object|string} body - body data to append to the request
21
+ * @property {object} errors - Map of errorCodes -> error messages
22
+ * @property {object} query - An object of query parameters to be encoded into the URL
23
+ * @property {object} headers - An object of headers to append to the request
24
+ * @property {string} parseAs - Parse the response body as json, text or stream
25
+ * @property {number} timeout - Request timeout in ms. Default: 300 seconds
26
+ */
27
+ /**
28
+ * Verify a Verifiable Credential with Inji Verify (V2).
29
+ *
30
+ * Posts to `{baseUrl}/v2/vc-verification`. Configure `baseUrl` with the
31
+ * service context path, e.g. `https://verify.example.org/v1/verify`.
32
+ *
33
+ * @example <caption>Verify a credential from state</caption>
34
+ * verify($.data, {
35
+ * skipStatusChecks: false,
36
+ * statusCheckFilters: ['revocation'],
37
+ * includeClaims: false,
38
+ * });
39
+ * @function
40
+ * @public
41
+ * @param {object|string} credential - JSON-LD object, SD-JWT string, or CWT hex string
42
+ * @param {VerifyOptions} [options={}] - Verification options
43
+ * @returns {Operation}
44
+ * @state {HttpState}
45
+ */
46
+ export function verify(credential: object | string, options?: VerifyOptions): Operation;
47
+ /**
48
+ * Make a general HTTP request to Inji Verify.
49
+ * Prefer {@link verify} for VC verification.
50
+ * @example
51
+ * request('POST', 'v2/vc-verification', {
52
+ * verifiableCredential: JSON.stringify($.data),
53
+ * skipStatusChecks: false,
54
+ * statusCheckFilters: ['revocation'],
55
+ * includeClaims: false,
56
+ * });
57
+ * @function
58
+ * @public
59
+ * @param {string} method - HTTP method to use
60
+ * @param {string} path - Path relative to configuration.baseUrl
61
+ * @param {object} body - Object attached to the request body
62
+ * @param {RequestOptions} [options={}] - Optional request options
63
+ * @returns {Operation}
64
+ * @state {HttpState}
65
+ */
66
+ export function request(method: string, path: string, body: object, options?: RequestOptions): Operation;
67
+ /**
68
+ * State object after an Inji Verify HTTP call
69
+ */
70
+ export type HttpState = {
71
+ /**
72
+ * - the parsed response body
73
+ */
74
+ data: any;
75
+ /**
76
+ * - the response from the HTTP server, including headers, statusCode, etc
77
+ */
78
+ response: any;
79
+ /**
80
+ * - an array of all previous data objects used in the Job
81
+ */
82
+ references: any;
83
+ };
84
+ /**
85
+ * Options for verify
86
+ */
87
+ export type VerifyOptions = any;
88
+ /**
89
+ * Options provided to a general HTTP request
90
+ */
91
+ export type RequestOptions = any;
92
+ export { as, combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, lastReferenceValue, map, merge, scrubEmojis, sourceValue, util } from "@openfn/language-common";
@@ -0,0 +1,3 @@
1
+ export function prepareNextState(state: any, response: any): any;
2
+ export function toVerifiableCredential(credential: object | string): string;
3
+ export function request(configuration: object, method: string, path: string, options?: object): any;
@@ -0,0 +1,3 @@
1
+ export default Adaptor;
2
+ export * from "./Adaptor";
3
+ import * as Adaptor from "./Adaptor";