@cinerino/sdk 11.0.0-alpha.7 → 11.0.0-alpha.9

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/lib/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * API Node.js Client
3
3
  */
4
- import { chevre, chevreAdmin, chevreAsset, chevreAuth, chevreConsole, chevrePay, chevreTxc, chevreTxn, cloudAdmin, cloudAsset, cloudPay, cloudTxc, cloudTxn, factory, loadChevre, loadChevreAdmin, loadChevreAsset, loadChevreAuth, loadChevreConsole, loadChevrePay, loadChevreTxc, loadChevreTxn, loadCloudAdmin, loadCloudAsset, loadCloudPay, loadCloudTxc, loadCloudTxn, loadPecorino, loadService, loadWaiterAdmin, pecorino, service, transporters, waiterAdmin } from './abstract';
4
+ import { chevre, chevreAdmin, chevreAsset, chevreConsole, chevrePay, chevreTxc, chevreTxn, cloudAdmin, cloudAsset, cloudPay, cloudTxc, cloudTxn, factory, loadChevre, loadChevreAdmin, loadChevreAsset, loadChevreConsole, loadChevrePay, loadChevreTxc, loadChevreTxn, loadCloudAdmin, loadCloudAsset, loadCloudPay, loadCloudTxc, loadCloudTxn, loadPecorino, loadService, loadWaiterAdmin, pecorino, service, transporters, waiterAdmin } from './abstract';
5
5
  import type ClientCredentialsClient from './auth/clientCredentialsClient';
6
6
  import type { ImplicitGrantClient, IOptions as IImplicitGrantClientOptions } from './auth/implicitGrantClient';
7
7
  import type OAuth2client from './auth/oAuth2client';
8
- export { loadChevre, loadChevreAdmin, loadChevreAsset, loadChevreAuth, loadChevreConsole, loadChevrePay, loadChevreTxc, loadChevreTxn, loadCloudAdmin, loadCloudAsset, loadCloudPay, loadCloudTxc, loadCloudTxn, loadPecorino, loadService, loadWaiterAdmin, chevre, chevreAdmin, chevreAsset, chevreAuth, chevreConsole, chevrePay, chevreTxc, chevreTxn, cloudAdmin, cloudAsset, cloudPay, cloudTxc, cloudTxn, pecorino, service, factory, transporters, waiterAdmin };
8
+ export { loadChevre, loadChevreAdmin, loadChevreAsset, loadChevreConsole, loadChevrePay, loadChevreTxc, loadChevreTxn, loadCloudAdmin, loadCloudAsset, loadCloudPay, loadCloudTxc, loadCloudTxn, loadPecorino, loadService, loadWaiterAdmin, chevre, chevreAdmin, chevreAsset, chevreConsole, chevrePay, chevreTxc, chevreTxn, cloudAdmin, cloudAsset, cloudPay, cloudTxc, cloudTxn, pecorino, service, factory, transporters, waiterAdmin };
9
9
  /**
10
10
  * each OAuth2 clients
11
11
  */
package/lib/index.js CHANGED
@@ -41,7 +41,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
41
41
  return to;
42
42
  };
43
43
  Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.createAuthInstance = exports.auth = exports.transporters = exports.factory = exports.loadWaiterAdmin = exports.loadService = exports.loadPecorino = exports.loadCloudTxn = exports.loadCloudTxc = exports.loadCloudPay = exports.loadCloudAsset = exports.loadCloudAdmin = exports.loadChevreTxn = exports.loadChevreTxc = exports.loadChevrePay = exports.loadChevreConsole = exports.loadChevreAuth = exports.loadChevreAsset = exports.loadChevreAdmin = exports.loadChevre = void 0;
44
+ exports.createAuthInstance = exports.auth = exports.transporters = exports.factory = exports.loadWaiterAdmin = exports.loadService = exports.loadPecorino = exports.loadCloudTxn = exports.loadCloudTxc = exports.loadCloudPay = exports.loadCloudAsset = exports.loadCloudAdmin = exports.loadChevreTxn = exports.loadChevreTxc = exports.loadChevrePay = exports.loadChevreConsole = exports.loadChevreAsset = exports.loadChevreAdmin = exports.loadChevre = void 0;
45
45
  /**
46
46
  * API Node.js Client
47
47
  */
@@ -50,7 +50,6 @@ Object.defineProperty(exports, "factory", { enumerable: true, get: function () {
50
50
  Object.defineProperty(exports, "loadChevre", { enumerable: true, get: function () { return abstract_1.loadChevre; } });
51
51
  Object.defineProperty(exports, "loadChevreAdmin", { enumerable: true, get: function () { return abstract_1.loadChevreAdmin; } });
52
52
  Object.defineProperty(exports, "loadChevreAsset", { enumerable: true, get: function () { return abstract_1.loadChevreAsset; } });
53
- Object.defineProperty(exports, "loadChevreAuth", { enumerable: true, get: function () { return abstract_1.loadChevreAuth; } });
54
53
  Object.defineProperty(exports, "loadChevreConsole", { enumerable: true, get: function () { return abstract_1.loadChevreConsole; } });
55
54
  Object.defineProperty(exports, "loadChevrePay", { enumerable: true, get: function () { return abstract_1.loadChevrePay; } });
56
55
  Object.defineProperty(exports, "loadChevreTxc", { enumerable: true, get: function () { return abstract_1.loadChevreTxc; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "11.0.0-alpha.7",
3
+ "version": "11.0.0-alpha.9",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -92,7 +92,7 @@
92
92
  "watchify": "^3.11.1"
93
93
  },
94
94
  "dependencies": {
95
- "@chevre/factory": "4.395.0-alpha.5",
95
+ "@chevre/factory": "4.395.0",
96
96
  "debug": "3.2.7",
97
97
  "http-status": "1.7.4",
98
98
  "idtoken-verifier": "2.0.3",
@@ -1,29 +0,0 @@
1
- // tslint:disable:no-console
2
- // tslint:disable-next-line:no-implicit-dependencies
3
- import { loadChevreAuth } from '../../../../lib/index';
4
- import { auth } from '../../auth/clientCredentials';
5
-
6
- const CODE = '455c255a-ab8c-483f-a1e3-3541c06e1150';
7
-
8
- async function main() {
9
- const authClient = await auth();
10
- const assertion = await authClient.getAccessToken();
11
- console.log('assertion:', assertion);
12
-
13
- const tokenService = await (await loadChevreAuth({
14
- endpoint: <string>process.env.CHEVRE_ENDPOINT_AUTH
15
- })).createTokenInstance();
16
-
17
- const result = await tokenService.getToken({
18
- grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
19
- assertion,
20
- code: CODE
21
- });
22
- console.log('result:', result);
23
- }
24
-
25
- main()
26
- .then(() => {
27
- console.log('success!');
28
- })
29
- .catch(console.error);
@@ -1,25 +0,0 @@
1
- import * as factory from '../factory';
2
- import { IOptions, Service } from '../service';
3
- declare type IIdentity = Pick<factory.creativeWork.certification.webApplication.ICertification, 'about' | 'id' | 'issuedBy'>;
4
- interface ISavingIdentity {
5
- clientId: string;
6
- clientSecret: string;
7
- iss: string[];
8
- }
9
- /**
10
- * アイデンティティサービス
11
- */
12
- export declare class IdentityService extends Service<IOptions> {
13
- constructor(options: Pick<IOptions, 'endpoint' | 'transporter'>);
14
- createIdentity(params: ISavingIdentity): Promise<{
15
- id: string;
16
- }>;
17
- projectIdentityFields(params: Omit<factory.creativeWork.certification.webApplication.ISearchConditions, 'project'>): Promise<IIdentity[]>;
18
- updateIdentityById(params: ISavingIdentity & {
19
- id: string;
20
- }): Promise<void>;
21
- deleteIdentityById(params: {
22
- id: string;
23
- }): Promise<void>;
24
- }
25
- export {};
@@ -1,152 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- var __rest = (this && this.__rest) || function (s, e) {
54
- var t = {};
55
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
56
- t[p] = s[p];
57
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
58
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
59
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60
- t[p[i]] = s[p[i]];
61
- }
62
- return t;
63
- };
64
- Object.defineProperty(exports, "__esModule", { value: true });
65
- exports.IdentityService = void 0;
66
- var http_status_1 = require("http-status");
67
- var service_1 = require("../service");
68
- /**
69
- * アイデンティティサービス
70
- */
71
- var IdentityService = /** @class */ (function (_super) {
72
- __extends(IdentityService, _super);
73
- function IdentityService(options) {
74
- var _this = this;
75
- var endpoint = options.endpoint, transporter = options.transporter;
76
- _this = _super.call(this, { endpoint: endpoint, transporter: transporter, project: { id: '' }, retryableStatusCodes: [] }) || this;
77
- return _this;
78
- }
79
- IdentityService.prototype.createIdentity = function (params) {
80
- return __awaiter(this, void 0, void 0, function () {
81
- var _this = this;
82
- return __generator(this, function (_a) {
83
- return [2 /*return*/, this.fetch({
84
- uri: '/identities',
85
- method: 'POST',
86
- body: params,
87
- expectedStatusCodes: [http_status_1.CREATED]
88
- })
89
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
90
- return [2 /*return*/, response.json()];
91
- }); }); })];
92
- });
93
- });
94
- };
95
- IdentityService.prototype.projectIdentityFields = function (params) {
96
- return __awaiter(this, void 0, void 0, function () {
97
- var _this = this;
98
- return __generator(this, function (_a) {
99
- return [2 /*return*/, this.fetch({
100
- uri: '/identities',
101
- method: 'GET',
102
- qs: params,
103
- expectedStatusCodes: [http_status_1.OK]
104
- })
105
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
106
- return [2 /*return*/, response.json()];
107
- }); }); })];
108
- });
109
- });
110
- };
111
- IdentityService.prototype.updateIdentityById = function (params) {
112
- return __awaiter(this, void 0, void 0, function () {
113
- var id, body;
114
- return __generator(this, function (_a) {
115
- switch (_a.label) {
116
- case 0:
117
- id = params.id, body = __rest(params, ["id"]);
118
- return [4 /*yield*/, this.fetch({
119
- uri: "/identities/" + encodeURIComponent(String(id)),
120
- method: 'PUT',
121
- body: body,
122
- expectedStatusCodes: [http_status_1.NO_CONTENT]
123
- })];
124
- case 1:
125
- _a.sent();
126
- return [2 /*return*/];
127
- }
128
- });
129
- });
130
- };
131
- IdentityService.prototype.deleteIdentityById = function (params) {
132
- return __awaiter(this, void 0, void 0, function () {
133
- var id;
134
- return __generator(this, function (_a) {
135
- switch (_a.label) {
136
- case 0:
137
- id = params.id;
138
- return [4 /*yield*/, this.fetch({
139
- uri: "/identities/" + encodeURIComponent(String(id)),
140
- method: 'DELETE',
141
- expectedStatusCodes: [http_status_1.NO_CONTENT]
142
- })];
143
- case 1:
144
- _a.sent();
145
- return [2 /*return*/];
146
- }
147
- });
148
- });
149
- };
150
- return IdentityService;
151
- }(service_1.Service));
152
- exports.IdentityService = IdentityService;
@@ -1,16 +0,0 @@
1
- import { IOptions, Service } from '../service';
2
- /**
3
- * チケットサービス
4
- */
5
- export declare class TicketService extends Service<IOptions> {
6
- constructor(options: Pick<IOptions, 'endpoint' | 'transporter'>);
7
- publish(params: {
8
- audience: {
9
- id: string;
10
- };
11
- expiresInSeconds: number;
12
- }): Promise<{
13
- token: string;
14
- expiresIn: number;
15
- }>;
16
- }
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.TicketService = void 0;
55
- var http_status_1 = require("http-status");
56
- var service_1 = require("../service");
57
- /**
58
- * チケットサービス
59
- */
60
- var TicketService = /** @class */ (function (_super) {
61
- __extends(TicketService, _super);
62
- function TicketService(options) {
63
- var _this = this;
64
- var endpoint = options.endpoint, transporter = options.transporter;
65
- _this = _super.call(this, { endpoint: endpoint, transporter: transporter, project: { id: '' }, retryableStatusCodes: [] }) || this;
66
- return _this;
67
- }
68
- TicketService.prototype.publish = function (params) {
69
- return __awaiter(this, void 0, void 0, function () {
70
- var _this = this;
71
- return __generator(this, function (_a) {
72
- return [2 /*return*/, this.fetch({
73
- uri: '/tickets',
74
- method: 'POST',
75
- body: params,
76
- expectedStatusCodes: [http_status_1.CREATED]
77
- })
78
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
79
- return [2 /*return*/, response.json()];
80
- }); }); })];
81
- });
82
- });
83
- };
84
- return TicketService;
85
- }(service_1.Service));
86
- exports.TicketService = TicketService;
@@ -1,20 +0,0 @@
1
- import { IOptions, Service } from '../service';
2
- export interface ICredentials {
3
- access_token: string;
4
- token_type: string;
5
- expires_in: number;
6
- }
7
- /**
8
- * トークンサービス
9
- */
10
- export declare class TokenService extends Service<IOptions> {
11
- constructor(options: Pick<IOptions, 'endpoint' | 'transporter'>);
12
- /**
13
- * トークンを取得する
14
- */
15
- getToken(params: {
16
- grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer';
17
- assertion: string;
18
- code: string;
19
- }): Promise<ICredentials>;
20
- }
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.TokenService = void 0;
55
- var http_status_1 = require("http-status");
56
- var service_1 = require("../service");
57
- /**
58
- * トークンサービス
59
- */
60
- var TokenService = /** @class */ (function (_super) {
61
- __extends(TokenService, _super);
62
- function TokenService(options) {
63
- var _this = this;
64
- var endpoint = options.endpoint, transporter = options.transporter;
65
- _this = _super.call(this, { endpoint: endpoint, transporter: transporter, project: { id: '' }, retryableStatusCodes: [] }) || this;
66
- return _this;
67
- }
68
- /**
69
- * トークンを取得する
70
- */
71
- TokenService.prototype.getToken = function (params) {
72
- return __awaiter(this, void 0, void 0, function () {
73
- var assertion, code, grant_type;
74
- var _this = this;
75
- return __generator(this, function (_a) {
76
- assertion = params.assertion, code = params.code, grant_type = params.grant_type;
77
- return [2 /*return*/, this.fetch({
78
- uri: '/token',
79
- method: 'POST',
80
- form: new URLSearchParams({ assertion: assertion, grant_type: grant_type }),
81
- qs: { code: code },
82
- expectedStatusCodes: [http_status_1.OK],
83
- headers: {
84
- 'Content-Type': 'application/x-www-form-urlencoded'
85
- }
86
- })
87
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
88
- return [2 /*return*/, response.json()];
89
- }); }); })];
90
- });
91
- });
92
- };
93
- return TokenService;
94
- }(service_1.Service));
95
- exports.TokenService = TokenService;
@@ -1,38 +0,0 @@
1
- import { IOptions, IUnset as IUnsetOnService } from './service';
2
- import type { IdentityService } from './chevreAuth/identity';
3
- import type { TicketService } from './chevreAuth/ticket';
4
- import type { TokenService } from './chevreAuth/token';
5
- export declare namespace service {
6
- type IUnset = IUnsetOnService;
7
- /**
8
- * トークンサービス
9
- */
10
- type Token = TokenService;
11
- namespace Token {
12
- let svc: typeof TokenService | undefined;
13
- }
14
- /**
15
- * アイデンティティサービス
16
- */
17
- type Identity = IdentityService;
18
- namespace Identity {
19
- let svc: typeof IdentityService | undefined;
20
- }
21
- /**
22
- * チケットサービス
23
- */
24
- type Ticket = TicketService;
25
- namespace Ticket {
26
- let svc: typeof TicketService | undefined;
27
- }
28
- }
29
- /**
30
- * 認可サービス
31
- */
32
- export declare class ChevreAuth {
33
- options: Pick<IOptions, 'endpoint'>;
34
- constructor(options: Pick<IOptions, 'endpoint'>);
35
- createTokenInstance(): Promise<TokenService>;
36
- createIdentityInstance(): Promise<IdentityService>;
37
- createTicketInstance(): Promise<TicketService>;
38
- }
@@ -1,123 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.ChevreAuth = exports.service = void 0;
51
- var service;
52
- (function (service) {
53
- var Token;
54
- (function (Token) {
55
- })(Token = service.Token || (service.Token = {}));
56
- var Identity;
57
- (function (Identity) {
58
- })(Identity = service.Identity || (service.Identity = {}));
59
- var Ticket;
60
- (function (Ticket) {
61
- })(Ticket = service.Ticket || (service.Ticket = {}));
62
- })(service = exports.service || (exports.service = {}));
63
- /**
64
- * 認可サービス
65
- */
66
- var ChevreAuth = /** @class */ (function () {
67
- function ChevreAuth(options) {
68
- this.options = options;
69
- }
70
- ChevreAuth.prototype.createTokenInstance = function () {
71
- return __awaiter(this, void 0, void 0, function () {
72
- var _a;
73
- return __generator(this, function (_b) {
74
- switch (_b.label) {
75
- case 0:
76
- if (!(service.Token.svc === undefined)) return [3 /*break*/, 2];
77
- _a = service.Token;
78
- return [4 /*yield*/, Promise.resolve().then(function () { return require('./chevreAuth/token'); })];
79
- case 1:
80
- _a.svc = (_b.sent()).TokenService;
81
- _b.label = 2;
82
- case 2: return [2 /*return*/, new service.Token.svc(__assign({}, this.options))];
83
- }
84
- });
85
- });
86
- };
87
- ChevreAuth.prototype.createIdentityInstance = function () {
88
- return __awaiter(this, void 0, void 0, function () {
89
- var _a;
90
- return __generator(this, function (_b) {
91
- switch (_b.label) {
92
- case 0:
93
- if (!(service.Identity.svc === undefined)) return [3 /*break*/, 2];
94
- _a = service.Identity;
95
- return [4 /*yield*/, Promise.resolve().then(function () { return require('./chevreAuth/identity'); })];
96
- case 1:
97
- _a.svc = (_b.sent()).IdentityService;
98
- _b.label = 2;
99
- case 2: return [2 /*return*/, new service.Identity.svc(__assign({}, this.options))];
100
- }
101
- });
102
- });
103
- };
104
- ChevreAuth.prototype.createTicketInstance = function () {
105
- return __awaiter(this, void 0, void 0, function () {
106
- var _a;
107
- return __generator(this, function (_b) {
108
- switch (_b.label) {
109
- case 0:
110
- if (!(service.Ticket.svc === undefined)) return [3 /*break*/, 2];
111
- _a = service.Ticket;
112
- return [4 /*yield*/, Promise.resolve().then(function () { return require('./chevreAuth/ticket'); })];
113
- case 1:
114
- _a.svc = (_b.sent()).TicketService;
115
- _b.label = 2;
116
- case 2: return [2 /*return*/, new service.Ticket.svc(__assign({}, this.options))];
117
- }
118
- });
119
- });
120
- };
121
- return ChevreAuth;
122
- }());
123
- exports.ChevreAuth = ChevreAuth;